服务器、中间件、CGI

参考链接:https://www.cnblogs.com/applelife/p/10496379.html
CGI:http://www.360doc.com/content/18/0327/17/51484742_740649523.shtml
CGI比较:https://www.jianshu.com/p/80e46a80fdbd%20%20

服务器

服务器指的是一个管理资源并为用户提供服务的计算机软件,通常分为文件服务器、数据库服务器和应用程序服务器。运行以上软件的计算机或计算机系统也被称为服务器。

中间件

中间件是服务器上负责解析http请求的一组应用程序,负责接收并解析http请求数据包,在服务器上找到数据包所请求的文件后,将其返回给客户端,如果http数据包所请求的是一个动态脚本文件,如php等,中间件就要靠CGI与脚本语言解析软件进行交互,处理好动态脚本文件后,再将处理后的文件其返回给浏览器。

说白了,中间件就是服务器上web端口(通常为80端口)的一个翻译官,负责告诉服务器用户要请求哪些文件,如果用户请求的是一个静态的html页面,就直接在服务器上找到对应文件并将其交给用户浏览器,如果用户请求的是一个动态页面如php,asp等,中间件在找到该文件后,将其交给对应的脚本语言解析程序,脚本语言解析程序将文件解析成html后,再把解析过的文件发送给浏览器。

所以,浏览器本身并不能渲染解析动态脚本文件,以php为例,浏览器解析的.php文件,实际上是经服务器php程序解析后的html文件。
再者,如果服务器上没有安装中间件,那么服务器就不能理解用户发来的http数据包是什么意思,当然也就无法对http请求包进行正确的响应。

CGI 通用网关接口

早期的Web服务器,只能响应浏览器发来的HTTP静态资源的请求,并将存储在服务器中的静态资源返回给浏览器。随着Web技术的发展,逐渐出现了动态技术,但是Web服务器并不能够直接运行动态脚本,为了解决Web服务器与外部应用程序之间数据互通,于是出现了CGI(Common Gateway Interface)通用网关接口。简单理解,可以认为CGI是Web服务器和运行其上的应用程序进行“交流”的一种约定。
(随着网站越来越复杂,出现动态技术。但是服务器并不能直接运行 php,asp这样的文件,自己不能做,外包给别人吧,但是要与第三做个约定,我给你什么,然后你给我什么,就是我把请求参数发送给你,然后我接收你的处理结果给客户端。那这个约定就是 common gateway interface,简称cgicgi只是接口协议)

CGI是Web服务器和一个独立的进程之间的协议,它会把HTTP请求RequestHeader头设置成进程的环境变量,HTTP请求的Body正文设置成进程的标准输入,进程的标准输出设置为HTTP响应Response,包含Header头和Body正文。
image.png
以php为例:
CGI就像翻译机,将PHP语言给服务器解释,便于相互之间的理解和通讯,最后呈现给浏览器。
请求动态资源的模型
image.png
服务器和客户端之间的通信,是客户端的浏览器和服务器端的http服务器之间的HTTP通信。
服务器和CGI程序之间是通过标准输入输出来进行数据传递的,而这个过程需要环境变量的协作方可实现。

在了解完基础的中间件、服务器、CGI知识之后,就能明确知道接下来的日志如何去查看了,因为可能会出现apache + tomcat 的部署关系,或者 nginx + tomcat。
总结:
有tomcat就看tomcat日志
无tomcat 就查看 nginx、apache。

中间件日志

IIS

IIS是一种Web(网页)服务组件,其中包括Web服务器、FTP服务器、NNTP服务器和SMTP服务器,分别用于网页浏览、文件传输、新闻服务和邮件发送等方面,它使得在网络(包括互联网和局域网)上发布信息成了一件很容易的事。

日志配置

日志存储路径:
image.png
image.png

日志内容配置:
image.png

access.log

以下是一段访问日志

  1. #Software: Microsoft Internet Information Services 7.5
  2. #Version: 1.0
  3. #Date: 2021-03-29 07:35:48
  4. #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
  5. 2021-03-29 07:35:48 172.16.50.134 GET / - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:87.0)+Gecko/20100101+Firefox/87.0 200 0 0 951
  6. 2021-03-29 07:35:48 172.16.50.134 GET /welcome.png - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:87.0)+Gecko/20100101+Firefox/87.0 200 0 0 15
  7. 2021-03-29 07:35:48 172.16.50.134 GET /favicon.ico - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:87.0)+Gecko/20100101+Firefox/87.0 404 0 2 46
  8. 2021-03-29 07:38:33 172.16.50.134 GET / - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 200 0 0 15
  9. 2021-03-29 07:38:33 172.16.50.134 GET /izza2hd01sGE - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  10. 2021-03-29 07:38:33 172.16.50.134 GET /87mA4jXxKqAc - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  11. 2021-03-29 07:38:33 172.16.50.134 GET /GEgvVZIVMtIN/ - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  12. 2021-03-29 07:38:33 172.16.50.134 GET /T9pjKFYb2FRq/ - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  13. 2021-03-29 07:38:33 172.16.50.134 GET /.gXVRIOICCQ1z - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  14. 2021-03-29 07:38:33 172.16.50.134 GET /.jaF9yfMPGql5 - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  15. 2021-03-29 07:38:33 172.16.50.134 GET /wTSnz2iF7rrq.* - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  16. 2021-03-29 07:38:33 172.16.50.134 GET /XyBAhd1HyxUB.* - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 15
  17. 2021-03-29 07:38:33 172.16.50.134 GET /+../ - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  18. 2021-03-29 07:38:33 172.16.50.134 GET /!.htpasswd - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0
  19. 2021-03-29 07:38:33 172.16.50.134 GET /*.bak - 80 - 172.16.10.121 Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1468.0+Safari/537.36 404 0 2 0

Apache

Apache HTTP服务器是一个模块化的服务器,可以运行在几乎所有广泛使用的计算机平台上。其属于应用服务器。Apache支持支持模块多,性能稳定,Apache本身是静态解析,适合静态HTML、图片等,但可以通过扩展脚本、模块等支持动态页面等。
(Apche可以支持PHPCGIPerl,但是要使用Java的话,你需要Tomcat在Apache后台支撑,将Java请求由Apache转发给Tomcat处理。) 缺点:配置相对复杂,自身不支持动态页面。

Apache日志详解

Apache日志文件名称及路径介绍

当我们安装并启动Apache后,Apache会自动生成两个日志文件,这两个日志文件分别是访问日志access_log(在Windows上是access.log)和错误日志error_log(在Windows上是error.log)。如果使用 SSL 服务的话,还可能存在 ssl_access_log和ssl_error_log 和 ssl_request_log 三种日志文件。
日志文件的路径根据安装方式不同位置也是不一样的,一般都是在Apache安装目录的logs子目录中,日志文件路径可根据实际安装情况在Apache的配置文件中进行查找。
Windows: \logs\access.log | error.log
Linux: /usr/local/apache/logs/access_log | error_log
https://blog.51cto.com/longlei/2095594
https://blog.csdn.net/u013699800/article/details/37593491
http://httpd.apache.org/docs/2.4/mod/mod_log_config.html#customlog
image.png

配置文件

配置文件路径
image.png
在apahce的配置文件中,可以定制详细的日志文件格式:
很久以前,日志文件只有一种格式,这就是“公共格式”,许多人已经习惯于使用这种格式。随后出现了定制日志格式,而且看起来定制日志格式更很受欢迎,即使公共日志格式本身也重新用定制日志格式定义。
定制日志文件的格式涉及到两个指令,即LogFormat指令和CustomLog指令。 默认httpd.conf文件提供了关于这两个指令的几个示例。
LogFormat指令:定义格式并为格式指定一个名字,以后我们就可以直接引用这个名字。
CustomLog指令:设置日志文件,并指明日志文件所用的格式(通常通过格式的名字)。
截取关键部分:(重点 6、7、27行)

  1. <IfModule log_config_module>
  2. #
  3. # The following directives define some format nicknames for use with
  4. # a CustomLog directive (see below).
  5. #
  6. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  7. LogFormat "%h %l %u %t \"%r\" %>s %b" common
  8. <IfModule logio_module>
  9. # You need to enable mod_logio.c to use %I and %O
  10. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  11. </IfModule>
  12. #
  13. # The location and format of the access logfile (Common Logfile Format).
  14. # If you do not define any access logfiles within a <VirtualHost>
  15. # container, they will be logged here. Contrariwise, if you *do*
  16. # define per-<VirtualHost> access logfiles, transactions will be
  17. # logged therein and *not* in this file.
  18. #
  19. #CustomLog "logs/access_log" common
  20. #
  21. # If you prefer a logfile with access, agent, and referer information
  22. # (Combined Logfile Format) you can use the following directive.
  23. #
  24. CustomLog "logs/access_log" combined
  25. </IfModule>
  • %a: 远程IP地址
  • %A: 本地IP地址
  • %B: 已发送的字节数,不包含HTTP头
  • %b: CLF格式的已发送字节数量,不包含HTTP头。例如当没有发送数据时,写入‘-’而不是0。
  • %{FOOBAR}e: 环境变量FOOBAR的内容
  • %f: 文件名字
  • %h: 远程主机
  • %H 请求的协议
  • %Foobar}i: Foobar的内容,发送给服务器的请求的标头行。
  • %l: 远程登录名字(来自identd,如提供的话)
  • %m: 请求的方法
  • %{Foobar}n: 来自另外一个模块的注解“Foobar”的内容
  • %{Foobar}o: Foobar的内容,应答的标头行
  • %p: 服务器响应请求时使用的端口
  • %P: 响应请求的子进程ID。
  • %q: 查询字符串(如果存在查询字符串,则包含“?”后面的部分;否则,它是一个空字符串。)
  • %r: 请求的第一行
  • %s: 状态。对于进行内部重定向的请求,这是指原来请求的状态。如果用%…>s,则是指后来的请求。
  • %t: 以公共日志时间格式表示的时间(或称为标准英文格式)
  • %{format}t: 以指定格式format表示的时间
  • %T: 为响应请求而耗费的时间,以秒计
  • %u: 远程用户(来自auth;如果返回状态(%s)是401则可能是伪造的)
  • %U: 用户所请求的URL路径
  • %v: 响应请求的服务器的ServerName
  • %V: 依照UseCanonicalName设置得到的服务器名字

完整的日志文件:

  1. #
  2. # This is the main Apache HTTP server configuration file. It contains the
  3. # configuration directives that give the server its instructions.
  4. # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
  5. # In particular, see
  6. # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
  7. # for a discussion of each configuration directive.
  8. #
  9. # Do NOT simply read the instructions in here without understanding
  10. # what they do. They're here only as hints or reminders. If you are unsure
  11. # consult the online docs. You have been warned.
  12. #
  13. # Configuration and logfile names: If the filenames you specify for many
  14. # of the server's control files begin with "/" (or "drive:/" for Win32), the
  15. # server will use that explicit path. If the filenames do *not* begin
  16. # with "/", the value of ServerRoot is prepended -- so 'log/access_log'
  17. # with ServerRoot set to '/www' will be interpreted by the
  18. # server as '/www/log/access_log', where as '/log/access_log' will be
  19. # interpreted as '/log/access_log'.
  20. #
  21. # ServerRoot: The top of the directory tree under which the server's
  22. # configuration, error, and log files are kept.
  23. #
  24. # Do not add a slash at the end of the directory path. If you point
  25. # ServerRoot at a non-local disk, be sure to specify a local disk on the
  26. # Mutex directive, if file-based mutexes are used. If you wish to share the
  27. # same ServerRoot for multiple httpd daemons, you will need to change at
  28. # least PidFile.
  29. #
  30. ServerRoot "/etc/httpd"
  31. #
  32. # Listen: Allows you to bind Apache to specific IP addresses and/or
  33. # ports, instead of the default. See also the <VirtualHost>
  34. # directive.
  35. #
  36. # Change this to Listen on specific IP addresses as shown below to
  37. # prevent Apache from glomming onto all bound IP addresses.
  38. #
  39. #Listen 12.34.56.78:80
  40. Listen 80
  41. #
  42. # Dynamic Shared Object (DSO) Support
  43. #
  44. # To be able to use the functionality of a module which was built as a DSO you
  45. # have to place corresponding `LoadModule' lines at this location so the
  46. # directives contained in it are actually available _before_ they are used.
  47. # Statically compiled modules (those listed by `httpd -l') do not need
  48. # to be loaded here.
  49. #
  50. # Example:
  51. # LoadModule foo_module modules/mod_foo.so
  52. #
  53. Include conf.modules.d/*.conf
  54. #
  55. # If you wish httpd to run as a different user or group, you must run
  56. # httpd as root initially and it will switch.
  57. #
  58. # User/Group: The name (or #number) of the user/group to run httpd as.
  59. # It is usually good practice to create a dedicated user and group for
  60. # running httpd, as with most system services.
  61. #
  62. User apache
  63. Group apache
  64. # 'Main' server configuration
  65. #
  66. # The directives in this section set up the values used by the 'main'
  67. # server, which responds to any requests that aren't handled by a
  68. # <VirtualHost> definition. These values also provide defaults for
  69. # any <VirtualHost> containers you may define later in the file.
  70. #
  71. # All of these directives may appear inside <VirtualHost> containers,
  72. # in which case these default settings will be overridden for the
  73. # virtual host being defined.
  74. #
  75. #
  76. # ServerAdmin: Your address, where problems with the server should be
  77. # e-mailed. This address appears on some server-generated pages, such
  78. # as error documents. e.g. admin@your-domain.com
  79. #
  80. ServerAdmin root@localhost
  81. #
  82. # ServerName gives the name and port that the server uses to identify itself.
  83. # This can often be determined automatically, but we recommend you specify
  84. # it explicitly to prevent problems during startup.
  85. #
  86. # If your host doesn't have a registered DNS name, enter its IP address here.
  87. #
  88. #ServerName www.example.com:80
  89. #
  90. # Deny access to the entirety of your server's filesystem. You must
  91. # explicitly permit access to web content directories in other
  92. # <Directory> blocks below.
  93. #
  94. <Directory />
  95. AllowOverride none
  96. Require all denied
  97. </Directory>
  98. #
  99. # Note that from this point forward you must specifically allow
  100. # particular features to be enabled - so if something's not working as
  101. # you might expect, make sure that you have specifically enabled it
  102. # below.
  103. #
  104. #
  105. # DocumentRoot: The directory out of which you will serve your
  106. # documents. By default, all requests are taken from this directory, but
  107. # symbolic links and aliases may be used to point to other locations.
  108. #
  109. DocumentRoot "/var/www/html"
  110. #
  111. # Relax access to content within /var/www.
  112. #
  113. <Directory "/var/www">
  114. AllowOverride None
  115. # Allow open access:
  116. Require all granted
  117. </Directory>
  118. # Further relax access to the default document root:
  119. <Directory "/var/www/html">
  120. #
  121. # Possible values for the Options directive are "None", "All",
  122. # or any combination of:
  123. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  124. #
  125. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  126. # doesn't give it to you.
  127. #
  128. # The Options directive is both complicated and important. Please see
  129. # http://httpd.apache.org/docs/2.4/mod/core.html#options
  130. # for more information.
  131. #
  132. Options Indexes FollowSymLinks
  133. #
  134. # AllowOverride controls what directives may be placed in .htaccess files.
  135. # It can be "All", "None", or any combination of the keywords:
  136. # Options FileInfo AuthConfig Limit
  137. #
  138. AllowOverride None
  139. #
  140. # Controls who can get stuff from this server.
  141. #
  142. Require all granted
  143. </Directory>
  144. #
  145. # DirectoryIndex: sets the file that Apache will serve if a directory
  146. # is requested.
  147. #
  148. <IfModule dir_module>
  149. DirectoryIndex index.html
  150. </IfModule>
  151. #
  152. # The following lines prevent .htaccess and .htpasswd files from being
  153. # viewed by Web clients.
  154. #
  155. <Files ".ht*">
  156. Require all denied
  157. </Files>
  158. #
  159. # ErrorLog: The location of the error log file.
  160. # If you do not specify an ErrorLog directive within a <VirtualHost>
  161. # container, error messages relating to that virtual host will be
  162. # logged here. If you *do* define an error logfile for a <VirtualHost>
  163. # container, that host's errors will be logged there and not here.
  164. #
  165. ErrorLog "logs/error_log"
  166. #
  167. # LogLevel: Control the number of messages logged to the error_log.
  168. # Possible values include: debug, info, notice, warn, error, crit,
  169. # alert, emerg.
  170. #
  171. LogLevel warn
  172. <IfModule log_config_module>
  173. #
  174. # The following directives define some format nicknames for use with
  175. # a CustomLog directive (see below).
  176. #
  177. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  178. LogFormat "%h %l %u %t \"%r\" %>s %b" common
  179. <IfModule logio_module>
  180. # You need to enable mod_logio.c to use %I and %O
  181. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  182. </IfModule>
  183. #
  184. # The location and format of the access logfile (Common Logfile Format).
  185. # If you do not define any access logfiles within a <VirtualHost>
  186. # container, they will be logged here. Contrariwise, if you *do*
  187. # define per-<VirtualHost> access logfiles, transactions will be
  188. # logged therein and *not* in this file.
  189. #
  190. #CustomLog "logs/access_log" common
  191. #
  192. # If you prefer a logfile with access, agent, and referer information
  193. # (Combined Logfile Format) you can use the following directive.
  194. #
  195. CustomLog "logs/access_log" combined
  196. </IfModule>
  197. <IfModule alias_module>
  198. #
  199. # Redirect: Allows you to tell clients about documents that used to
  200. # exist in your server's namespace, but do not anymore. The client
  201. # will make a new request for the document at its new location.
  202. # Example:
  203. # Redirect permanent /foo http://www.example.com/bar
  204. #
  205. # Alias: Maps web paths into filesystem paths and is used to
  206. # access content that does not live under the DocumentRoot.
  207. # Example:
  208. # Alias /webpath /full/filesystem/path
  209. #
  210. # If you include a trailing / on /webpath then the server will
  211. # require it to be present in the URL. You will also likely
  212. # need to provide a <Directory> section to allow access to
  213. # the filesystem path.
  214. #
  215. # ScriptAlias: This controls which directories contain server scripts.
  216. # ScriptAliases are essentially the same as Aliases, except that
  217. # documents in the target directory are treated as applications and
  218. # run by the server when requested rather than as documents sent to the
  219. # client. The same rules about trailing "/" apply to ScriptAlias
  220. # directives as to Alias.
  221. #
  222. ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
  223. </IfModule>
  224. #
  225. # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
  226. # CGI directory exists, if you have that configured.
  227. #
  228. <Directory "/var/www/cgi-bin">
  229. AllowOverride None
  230. Options None
  231. Require all granted
  232. </Directory>
  233. <IfModule mime_module>
  234. #
  235. # TypesConfig points to the file containing the list of mappings from
  236. # filename extension to MIME-type.
  237. #
  238. TypesConfig /etc/mime.types
  239. #
  240. # AddType allows you to add to or override the MIME configuration
  241. # file specified in TypesConfig for specific file types.
  242. #
  243. #AddType application/x-gzip .tgz
  244. #
  245. # AddEncoding allows you to have certain browsers uncompress
  246. # information on the fly. Note: Not all browsers support this.
  247. #
  248. #AddEncoding x-compress .Z
  249. #AddEncoding x-gzip .gz .tgz
  250. #
  251. # If the AddEncoding directives above are commented-out, then you
  252. # probably should define those extensions to indicate media types:
  253. #
  254. AddType application/x-compress .Z
  255. AddType application/x-gzip .gz .tgz
  256. #
  257. # AddHandler allows you to map certain file extensions to "handlers":
  258. # actions unrelated to filetype. These can be either built into the server
  259. # or added with the Action directive (see below)
  260. #
  261. # To use CGI scripts outside of ScriptAliased directories:
  262. # (You will also need to add "ExecCGI" to the "Options" directive.)
  263. #
  264. #AddHandler cgi-script .cgi
  265. # For type maps (negotiated resources):
  266. #AddHandler type-map var
  267. #
  268. # Filters allow you to process content before it is sent to the client.
  269. #
  270. # To parse .shtml files for server-side includes (SSI):
  271. # (You will also need to add "Includes" to the "Options" directive.)
  272. #
  273. AddType text/html .shtml
  274. AddOutputFilter INCLUDES .shtml
  275. </IfModule>
  276. #
  277. # Specify a default charset for all content served; this enables
  278. # interpretation of all content as UTF-8 by default. To use the
  279. # default browser choice (ISO-8859-1), or to allow the META tags
  280. # in HTML content to override this choice, comment out this
  281. # directive:
  282. #
  283. AddDefaultCharset UTF-8
  284. <IfModule mime_magic_module>
  285. #
  286. # The mod_mime_magic module allows the server to use various hints from the
  287. # contents of the file itself to determine its type. The MIMEMagicFile
  288. # directive tells the module where the hint definitions are located.
  289. #
  290. MIMEMagicFile conf/magic
  291. </IfModule>
  292. #
  293. # Customizable error responses come in three flavors:
  294. # 1) plain text 2) local redirects 3) external redirects
  295. #
  296. # Some examples:
  297. #ErrorDocument 500 "The server made a boo boo."
  298. #ErrorDocument 404 /missing.html
  299. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  300. #ErrorDocument 402 http://www.example.com/subscription_info.html
  301. #
  302. #
  303. # EnableMMAP and EnableSendfile: On systems that support it,
  304. # memory-mapping or the sendfile syscall may be used to deliver
  305. # files. This usually improves server performance, but must
  306. # be turned off when serving from networked-mounted
  307. # filesystems or if support for these functions is otherwise
  308. # broken on your system.
  309. # Defaults if commented: EnableMMAP On, EnableSendfile Off
  310. #
  311. #EnableMMAP off
  312. EnableSendfile on
  313. # Supplemental configuration
  314. #
  315. # Load config files in the "/etc/httpd/conf.d" directory, if any.
  316. IncludeOptional conf.d/*.conf

access_log

格式:
1.远程主机IP 2.空白(E-mail) 3.空白(登录名) 4.请求时间 5.方法、资源、协议 6.响应码 7.发送字节 8.referer 9.UA
这一些内容都是配置文件中决定的

  1. [root@localhost httpd]# head -n 100 access_log-20210328
  2. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET / HTTP/1.1" 403 4897 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  3. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/bootstrap.min.css HTTP/1.1" 200 19341 "http://172.16.50.185/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  4. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "http://172.16.50.185/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  5. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /images/apache_pb.gif HTTP/1.1" 200 2326 "http://172.16.50.185/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  6. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /images/poweredby.png HTTP/1.1" 200 3956 "http://172.16.50.185/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  7. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.woff HTTP/1.1" 404 239 "http://172.16.50.185/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  8. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.woff HTTP/1.1" 404 241 "http://172.16.50.185/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  9. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://172.16.50.185/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  10. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.ttf HTTP/1.1" 404 238 "http://172.16.50.185/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  11. 172.16.10.121 - - [25/Mar/2021:12:24:24 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://172.16.50.185/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  12. 172.16.10.121 - - [25/Mar/2021:12:24:28 +0800] "GET /sqli-labs/ HTTP/1.1" 200 7933 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  13. 172.16.10.121 - - [25/Mar/2021:12:24:28 +0800] "GET /sqli-labs/index.html_files/freemind2html.css HTTP/1.1" 200 1335 "http://172.16.50.185/sqli-labs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  14. 172.16.10.121 - - [25/Mar/2021:12:24:28 +0800] "GET /sqli-labs/index.html_files/freemind2html.js HTTP/1.1" 404 241 "http://172.16.50.185/sqli-labs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  15. 172.16.10.121 - - [25/Mar/2021:12:24:28 +0800] "GET /sqli-labs/index.html_files/image.png HTTP/1.1" 200 81003 "http://172.16.50.185/sqli-labs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  16. 172.16.10.121 - - [25/Mar/2021:12:24:43 +0800] "GET /sqli-labs/Less-8 HTTP/1.1" 301 246 "http://172.16.50.185/sqli-labs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  17. 172.16.10.121 - - [25/Mar/2021:12:24:43 +0800] "GET /sqli-labs/Less-8/ HTTP/1.1" 200 694 "http://172.16.50.185/sqli-labs/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  18. 172.16.10.121 - - [25/Mar/2021:12:24:43 +0800] "GET /sqli-labs/images/Less-8.jpg HTTP/1.1" 200 24369 "http://172.16.50.185/sqli-labs/Less-8/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  19. 172.16.10.121 - - [25/Mar/2021:12:24:48 +0800] "GET /sqli-labs/Less-8/?id=1 HTTP/1.1" 200 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  20. 172.16.10.121 - - [25/Mar/2021:12:24:55 +0800] "GET /sqli-labs/Less-8/?id=1%27 HTTP/1.1" 200 722 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
  21. 172.16.10.121 - - [25/Mar/2021:12:25:04 +0800] "GET /sqli-labs/Less-8/?id=1 HTTP/1.1" 200 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"

Nginx

Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的。从2004年发布至今,凭借开源的力量,已经接近成熟与完善。
Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。支持FastCGI、SSL、Virtual Host、URL Rewrite、Gzip等功能。并且支持很多第三方的模块扩展。

配置文件

image.png
conf文件夹的nginx.conf文件,Nginx服务器的基础配置,默认的配置也存放在此。
在 nginx.conf 的注释符号为: #
默认的 nginx 配置文件 nginx.conf 内容如下:

  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. # '$status $body_bytes_sent "$http_referer" '
  15. # '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log logs/access.log main;
  17. sendfile on;
  18. #tcp_nopush on;
  19. #keepalive_timeout 0;
  20. keepalive_timeout 65;
  21. #gzip on;
  22. server {
  23. listen 80;
  24. server_name localhost;
  25. #charset koi8-r;
  26. #access_log logs/host.access.log main;
  27. location / {
  28. root html;
  29. index index.html index.htm;
  30. }
  31. #error_page 404 /404.html;
  32. # redirect server error pages to the static page /50x.html
  33. #
  34. error_page 500 502 503 504 /50x.html;
  35. location = /50x.html {
  36. root html;
  37. }
  38. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  39. #
  40. #location ~ \.php$ {
  41. # proxy_pass http://127.0.0.1;
  42. #}
  43. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  44. #
  45. #location ~ \.php$ {
  46. # root html;
  47. # fastcgi_pass 127.0.0.1:9000;
  48. # fastcgi_index index.php;
  49. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  50. # include fastcgi_params;
  51. #}
  52. # deny access to .htaccess files, if Apache's document root
  53. # concurs with nginx's one
  54. #
  55. #location ~ /\.ht {
  56. # deny all;
  57. #}
  58. }
  59. # another virtual host using mix of IP-, name-, and port-based configuration
  60. #
  61. #server {
  62. # listen 8000;
  63. # listen somename:8080;
  64. # server_name somename alias another.alias;
  65. # location / {
  66. # root html;
  67. # index index.html index.htm;
  68. # }
  69. #}
  70. # HTTPS server
  71. #
  72. #server {
  73. # listen 443 ssl;
  74. # server_name localhost;
  75. # ssl_certificate cert.pem;
  76. # ssl_certificate_key cert.key;
  77. # ssl_session_cache shared:SSL:1m;
  78. # ssl_session_timeout 5m;
  79. # ssl_ciphers HIGH:!aNULL:!MD5;
  80. # ssl_prefer_server_ciphers on;
  81. # location / {
  82. # root html;
  83. # index index.html index.htm;
  84. # }
  85. #}
  86. }

nginx 文件结构

  1. ... #全局块
  2. events { #events块
  3. ...
  4. }
  5. http #http块
  6. {
  7. ... #http全局块
  8. server #server块
  9. {
  10. ... #server全局块
  11. location [PATTERN] #location块
  12. {
  13. ...
  14. }
  15. location [PATTERN]
  16. {
  17. ...
  18. }
  19. }
  20. server
  21. {
  22. ...
  23. }
  24. ... #http全局块
  25. }
  • 1、全局块:配置影响nginx全局的指令。一般有运行nginx服务器的用户组,nginx进程pid存放路径,日志存放路径,配置文件引入,允许生成worker process数等。
  • 2、events块:配置影响nginx服务器或与用户的网络连接。有每个进程的最大连接数,选取哪种事件驱动模型处理连接请求,是否允许同时接受多个网路连接,开启多个网络连接序列化等。
  • 3、http块:可以嵌套多个server,配置代理,缓存,日志定义等绝大多数功能和第三方模块的配置。如文件引入,mime-type定义,日志自定义,是否使用sendfile传输文件,连接超时时间,单连接请求数等。
  • 4、server块:配置虚拟主机的相关参数,一个http中可以有多个server。
  • 5、location块:配置请求的路由,以及各种页面的处理情况。

可以参照这个配置文件,注意绿色的那一部分,也就是日志内容

  1. ########### 每个指令必须有分号结束。#################
  2. #user administrator administrators; #配置用户或者组,默认为nobody nobody。
  3. #worker_processes 2; #允许生成的进程数,默认为1
  4. #pid /nginx/pid/nginx.pid; #指定nginx进程运行文件存放地址
  5. error_log log/error.log debug; #制定日志路径,级别。这个设置可以放入全局块,http块,server块,级别以此为:debug|info|notice|warn|error|crit|alert|emerg
  6. events {
  7. accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on
  8. multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为off
  9. #use epoll; #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
  10. worker_connections 1024; #最大连接数,默认为512
  11. }
  12. http {
  13. include mime.types; #文件扩展名与文件类型映射表
  14. default_type application/octet-stream; #默认文件类型,默认为text/plain
  15. #access_log off; #取消服务日志
  16. log_format myFormat '$remote_addr–$remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for'; #自定义格式
  17. access_log log/access.log myFormat; #combined为日志格式的默认值
  18. sendfile on; #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
  19. sendfile_max_chunk 100k; #每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
  20. keepalive_timeout 65; #连接超时时间,默认为75s,可以在http,server,location块。
  21. upstream mysvr {
  22. server 127.0.0.1:7878;
  23. server 192.168.10.121:3333 backup; #热备
  24. }
  25. error_page 404 https://www.baidu.com; #错误页
  26. server {
  27. keepalive_requests 120; #单连接请求上限次数。
  28. listen 4545; #监听端口
  29. server_name 127.0.0.1; #监听地址
  30. location ~*^.+$ { #请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。
  31. #root path; #根目录
  32. #index vv.txt; #设置默认页
  33. proxy_pass http://mysvr; #请求转向mysvr 定义的服务器列表
  34. deny 127.0.0.1; #拒绝的ip
  35. allow 172.18.5.54; #允许的ip
  36. }
  37. }
  38. }
  • 1.$remote_addr 与 $http_x_forwarded_for 用以记录客户端的ip地址;
  • 2.$remote_user :用来记录客户端用户名称;
  • 3.$time_local : 用来记录访问时间与时区;
  • 4.$request : 用来记录请求的url与http协议;
  • 5.$status : 用来记录请求状态;成功是200;
  • 6.$body_bytes_s ent :记录发送给客户端文件主体内容大小;
  • 7.$http_referer :用来记录从那个页面链接访问过来的;
  • 8.$http_user_agent :记录客户端浏览器的相关信息;

参照我本地的nginx

image.png

日志文件

Nginx日志主要分为两种:access_log(访问日志)和error_log(错误日志)。通过访问日志我们可以得到用户的IP地址、浏览器的信息,请求的处理时间等信息。错误日志记录了访问出错的信息,可以帮助我们定位错误的原因。nginx的日志不会自动分割。

access_log

路径参照配置文件就可以找到,日志的详细内容需要参考nginx.conf中的配置文件
例如我本地配置为:

  1. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  2. '$status $body_bytes_sent "$http_referer" '
  3. '"$http_user_agent" "$http_x_forwarded_for"';
  4. access_log logs/access.log main;

远程地址 用户 时间 请求方法 状态码 发送的字节 referer ua xff

  1. 10.11.243.33 - - [05/Jan/2021:17:07:27 +0800] "GET / HTTP/1.1" 200 1214 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0" "-"
  2. 10.11.243.33 - - [05/Jan/2021:17:07:33 +0800] "GET /favicon.ico HTTP/1.1" 404 711 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0" "-"
  3. 10.11.243.33 - - [05/Jan/2021:17:07:36 +0800] "GET / HTTP/1.1" 200 1214 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0" "-"
  4. 10.11.241.10 - - [12/Jan/2021:17:59:32 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  5. 10.11.241.10 - - [12/Jan/2021:18:52:25 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  6. 10.11.241.10 - - [12/Jan/2021:18:54:50 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/4.75 [en] (X11, U; Scanner)" "-"
  7. 10.11.241.10 - - [12/Jan/2021:18:55:00 +0800] "GET /en-US/account/login HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  8. 10.11.241.10 - - [12/Jan/2021:18:55:27 +0800] "GET /portal/ HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  9. 10.11.241.10 - - [12/Jan/2021:18:55:58 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  10. 10.11.241.10 - - [12/Jan/2021:18:56:44 +0800] "GET /server_version.xsl HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  11. 10.11.241.10 - - [12/Jan/2021:18:58:26 +0800] "GET /_profiler/latest HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  12. 10.11.241.10 - - [12/Jan/2021:18:58:37 +0800] "GET /web/app_dev.php/_configurator/step/0 HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  13. 10.11.241.10 - - [12/Jan/2021:18:58:46 +0800] "GET /app.php HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  14. 10.11.241.10 - - [12/Jan/2021:19:02:55 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  15. 10.11.241.10 - - [12/Jan/2021:19:02:58 +0800] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  16. 10.11.241.10 - - [12/Jan/2021:19:16:56 +0800] "GET http://www.openvas.org/openvas-proxy-test HTTP/1.1" 499 0 "-" "Mozilla/5.0 [en] (X11, U; Scanner )" "-"
  17. 10.11.241.10 - - [13/Jan/2021:16:28:58 +0800] "GET / HTTP/1.1" 504 494 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" "-"
  18. 10.11.241.10 - - [13/Jan/2021:16:29:24 +0800] "GET /favicon.ico HTTP/1.1" 499 0 "http://10.11.242.34:8000/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" "-"
  19. 10.11.242.36 - - [13/Jan/2021:16:33:45 +0800] "HEAD / HTTP/1.1" 502 0 "-" "curl/7.29.0" "-"
  20. 10.11.241.10 - - [13/Jan/2021:16:34:04 +0800] "GET / HTTP/1.1" 504 494 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" "-"
  21. 10.11.241.10 - - [13/Jan/2021:16:35:04 +0800] "GET /favicon.ico HTTP/1.1" 502 494 "http://10.11.242.34:8000/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" "-"

error_log

错误日志主要记录客户端访问Nginx出错时的日志,格式不支持自定义。通过错误日志,你可以得到系统某个服务或server的性能瓶颈等。

  1. [root@localhost logs]# head -n 100 error.log
  2. 2021/01/05 14:20:00 [emerg] 11437#0: duplicate location "/" in /asap/nginx/conf/domains/8000.conf:14
  3. 2021/01/05 14:21:06 [emerg] 11441#0: duplicate location "/" in /asap/nginx/conf/domains/8000.conf:14
  4. 2021/01/05 14:23:36 [notice] 11465#0: signal process started
  5. 2021/01/05 14:26:01 [emerg] 11526#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  6. 2021/01/05 14:26:01 [emerg] 11526#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  7. 2021/01/05 14:26:01 [emerg] 11526#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  8. 2021/01/05 14:26:01 [emerg] 11526#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  9. 2021/01/05 14:26:01 [emerg] 11526#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  10. 2021/01/05 14:26:01 [emerg] 11526#0: still could not bind()
  11. 2021/01/05 14:27:01 [emerg] 11548#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  12. 2021/01/05 14:27:01 [emerg] 11548#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  13. 2021/01/05 14:27:01 [emerg] 11548#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  14. 2021/01/05 14:27:01 [emerg] 11548#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)
  15. 2021/01/05 14:27:01 [emerg] 11548#0: bind() to 0.0.0.0:8000 failed (98: Address already in use)

Tomcat

参考链接:https://www.cnblogs.com/operationhome/p/9680040.html

Tomcat 对应日志的配置文件:tomcat目录下的/conf/logging.properties。
image.png
Tomcat 的日志等级有:日志输出级别:SEVERE (最高级别) > WARNING > INFO > CONFIG > FINE > FINER(精心) > FINEST (所有内容,最低级别)
使用日志输出级别越高那么tomcat对内存的消耗就越低

Tomcat 有五类日志 :catalina、localhost、manager、admin、host-manager
image.png
/conf/logging.properties 配置文件:

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #可配置项(5类日志):catalina、localhost、manager、admin、host-manager
  16. handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
  17. #日志输出为输出到文件和输出到控制台
  18. .handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
  19. ############################################################
  20. # Handler specific properties.
  21. # Describes specific configuration info for Handlers.
  22. ############################################################
  23. #日志输出级别:SEVERE (最高级别) > WARNING > INFO > CONFIG > FINE > FINER(精心) > FINEST (所有内容,最低级别)
  24. #配置文件使catalina日志输出级别为FINE
  25. 1catalina.org.apache.juli.AsyncFileHandler.level = FINE
  26. #catalina文件输出位置
  27. 1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
  28. #catalina日志前缀为catalina
  29. 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
  30. 1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8
  31. 2localhost.org.apache.juli.AsyncFileHandler.level = FINE
  32. 2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
  33. 2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
  34. 2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8
  35. 3manager.org.apache.juli.AsyncFileHandler.level = FINE
  36. 3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
  37. 3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
  38. 3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
  39. 4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
  40. 4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
  41. 4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
  42. 4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
  43. #配置文件使控制台日志输出级别为FINE
  44. java.util.logging.ConsoleHandler.level = FINE
  45. java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
  46. java.util.logging.ConsoleHandler.encoding = UTF-8
  47. ############################################################
  48. # Facility specific properties.
  49. # Provides extra control for each logger.
  50. ############################################################
  51. #localhost日志文件输出级别为INFO
  52. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
  53. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler
  54. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
  55. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler
  56. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
  57. org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler
  58. # For example, set the org.apache.catalina.util.LifecycleBase logger to log
  59. # each component that extends LifecycleBase changing state:
  60. #org.apache.catalina.util.LifecycleBase.level = FINE
  61. # To see debug messages in TldLocationsCache, uncomment the following line:
  62. #org.apache.jasper.compiler.TldLocationsCache.level = FINE
  63. # To see debug messages for HTTP/2 handling, uncomment the following line:
  64. #org.apache.coyote.http2.level = FINE
  65. # To see debug messages for WebSocket handling, uncomment the following line:
  66. #org.apache.tomcat.websocket.level = FINE


日志文件详解

catalina.out

即标准输出和标准出错,所有输出到这两个位置的都会进入catalina.out,这里包含tomcat运行自己输出的日志以及应用里向console输出的日志。默认这个日志文件是不会进行自动切割的,我们需要借助其他工具进行切割(注意:catalina.out文件如果过大会影响)
image.png
截取的部分日志内容

  1. [root@localhost logs]# head -n 100 catalina.out
  2. 28-Dec-2020 18:07:49.782 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/8.5.61
  3. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Dec 3 2020 14:03:28 UTC
  4. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号: 8.5.61.0
  5. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 操作系统名称: Linux
  6. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 3.10.0-693.el7.x86_64
  7. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: amd64
  8. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: /usr/java/jdk1.8.0_271-amd64/jre
  9. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java虚拟机版本: 1.8.0_271-b09
  10. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Oracle Corporation
  11. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/apache-tomcat-8.5.61
  12. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/apache-tomcat-8.5.61
  13. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.5.61/conf/logging.properties
  14. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  15. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048
  16. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
  17. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
  18. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dignore.endorsed.dirs=
  19. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.base=/usr/local/apache-tomcat-8.5.61
  20. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.home=/usr/local/apache-tomcat-8.5.61
  21. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.io.tmpdir=/usr/local/apache-tomcat-8.5.61/temp
  22. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent java.library.path:[/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]上找不到基于APRApache Tomcat本机库,该库允许在生产环境中获得最佳性能
  23. 28-Dec-2020 18:07:49.883 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"]
  24. 28-Dec-2020 18:07:49.893 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
  25. 28-Dec-2020 18:07:49.901 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 476 ms
  26. 28-Dec-2020 18:07:49.919 信息 [main] org.apache.catalina.core.StandardService.startInternal 正在启动服务[Catalina]
  27. 28-Dec-2020 18:07:49.919 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.61
  28. 28-Dec-2020 18:07:49.929 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/ROOT]
  29. 28-Dec-2020 18:07:50.099 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/ROOT]的部署已在[169]毫秒内完成
  30. 28-Dec-2020 18:07:50.099 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/docs]
  31. 28-Dec-2020 18:07:50.110 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/docs]的部署已在[11]毫秒内完成
  32. 28-Dec-2020 18:07:50.110 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/examples]
  33. 28-Dec-2020 18:07:50.249 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/examples]的部署已在[139]毫秒内完成
  34. 28-Dec-2020 18:07:50.250 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/host-manager]
  35. 28-Dec-2020 18:07:50.264 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/host-manager]的部署已在[14]毫秒内完成
  36. 28-Dec-2020 18:07:50.265 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/manager]
  37. 28-Dec-2020 18:07:50.276 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/manager]的部署已在[11]毫秒内完成
  38. 28-Dec-2020 18:07:50.279 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"]

catalina.YYYY-MM-DD.log

catalina.{yyyy-MM-dd}.log是tomcat自己运行的一些日志,这些日志还会输出到catalina.out,但是应用向console输出的日志不会输出到catalina.{yyyy-MM-dd}.log,它是tomcat的启动和暂停时的运行日志,注意,它和catalina.out是里面的内容是不一样的。
对比两段日志可以看到 tomcat自己运行的日志分别输出到 catalina.out 与catalina.2020-12-28.log中。

  1. [root@localhost logs]# head -n 100 catalina.2020-12-28.log
  2. 28-Dec-2020 18:07:49.782 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/8.5.61
  3. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Dec 3 2020 14:03:28 UTC
  4. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号: 8.5.61.0
  5. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 操作系统名称: Linux
  6. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 3.10.0-693.el7.x86_64
  7. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: amd64
  8. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: /usr/java/jdk1.8.0_271-amd64/jre
  9. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java虚拟机版本: 1.8.0_271-b09
  10. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Oracle Corporation
  11. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/apache-tomcat-8.5.61
  12. 28-Dec-2020 18:07:49.785 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/apache-tomcat-8.5.61
  13. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.5.61/conf/logging.properties
  14. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  15. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048
  16. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
  17. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
  18. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dignore.endorsed.dirs=
  19. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.base=/usr/local/apache-tomcat-8.5.61
  20. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.home=/usr/local/apache-tomcat-8.5.61
  21. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.io.tmpdir=/usr/local/apache-tomcat-8.5.61/temp
  22. 28-Dec-2020 18:07:49.786 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent java.library.path:[/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]上找不到基于APRApache Tomcat本机库,该库允许在生产环境中获得最佳性能
  23. 28-Dec-2020 18:07:49.883 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"]
  24. 28-Dec-2020 18:07:49.893 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
  25. 28-Dec-2020 18:07:49.901 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 476 ms
  26. 28-Dec-2020 18:07:49.919 信息 [main] org.apache.catalina.core.StandardService.startInternal 正在启动服务[Catalina]
  27. 28-Dec-2020 18:07:49.919 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.61
  28. 28-Dec-2020 18:07:49.929 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/ROOT]
  29. 28-Dec-2020 18:07:50.099 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/ROOT]的部署已在[169]毫秒内完成
  30. 28-Dec-2020 18:07:50.099 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/docs]
  31. 28-Dec-2020 18:07:50.110 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/docs]的部署已在[11]毫秒内完成
  32. 28-Dec-2020 18:07:50.110 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/examples]
  33. 28-Dec-2020 18:07:50.249 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/examples]的部署已在[139]毫秒内完成
  34. 28-Dec-2020 18:07:50.250 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/host-manager]
  35. 28-Dec-2020 18:07:50.264 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/host-manager]的部署已在[14]毫秒内完成
  36. 28-Dec-2020 18:07:50.265 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/manager]
  37. 28-Dec-2020 18:07:50.276 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/usr/local/apache-tomcat-8.5.61/webapps/manager]的部署已在[11]毫秒内完成
  38. 28-Dec-2020 18:07:50.279 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"]
  39. 28-Dec-2020 18:07:50.290 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 388 ms
  40. 28-Dec-2020 18:19:00.479 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory web 应用程序部署到目录 [/usr/local/apache-tomcat-8.5.61/webapps/netBank]
  41. 28-Dec-2020 18:19:01.288 信息 [localhost-startStop-2] org.apache.jasper.servlet.TldScanner.scanJars 至少有一个JAR被扫描用于TLD但尚未包含TLD 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。
  42. 28-Dec-2020 18:19:01.307 信息 [localhost-startStop-2] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
  43. 28-Dec-2020 18:19:01.351 信息 [localhost-startStop-2] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Mon Dec 28 18:19:01 CST 2020]; root of context hierarchy
  44. 28-Dec-2020 18:19:01.380 信息 [localhost-startStop-2] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from class path resource [applicationContext.xml]
  45. 28-Dec-2020 18:19:01.573 信息 [localhost-startStop-2] org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2ee80376: defining beans [dataSource,sessionFactory,userDao,userService,user,admin,personinfoDao,personinfoService,personinfo,transactionDao,transactionService,transaction,transactionManager,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
  46. 28-Dec-2020 18:19:01.692 INFO [localhost-startStop-2] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
  47. 28-Dec-2020 18:19:01.697 INFO [localhost-startStop-2] org.hibernate.Version.logVersion HHH000412: Hibernate Core {4.2.2.Final}
  48. 28-Dec-2020 18:19:01.698 INFO [localhost-startStop-2] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
  49. 28-Dec-2020 18:19:01.700 INFO [localhost-startStop-2] org.hibernate.cfg.Environment.buildBytecodeProvider HHH000021: Bytecode provider name : javassist
  50. 28-Dec-2020 18:19:01.727 WARN [localhost-startStop-2] org.hibernate.internal.util.xml.DTDEntityResolver.resolveEntity HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

localhost.YYYY-MM-DD.log

localhost.{yyyy-MM-dd}.log主要是应用初始化(listener, filter, servlet)未处理的异常最后被tomcat捕获而输出的日志,它也是包含tomcat的启动和暂停时的运行日志,但它没有catalina.2020-12-28.log 日志全。它只是记录了部分日志。

  1. [root@localhost logs]# head -n 100 localhost.2020-12-28.log
  2. 28-Dec-2020 18:07:50.243 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
  3. 28-Dec-2020 18:07:50.243 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
  4. 28-Dec-2020 18:07:50.244 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@17784821')
  5. 28-Dec-2020 18:19:01.289 信息 [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
  6. 28-Dec-2020 18:19:01.307 信息 [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
  7. 28-Dec-2020 18:20:45.565 信息 [localhost-startStop-5] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
  8. 28-Dec-2020 18:20:51.421 信息 [localhost-startStop-5] org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
  9. 28-Dec-2020 18:20:56.474 信息 [localhost-startStop-5] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'backendDispatcherServlet'
  10. 28-Dec-2020 18:22:22.737 信息 [http-nio-8080-exec-4] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'dispatcherServlet'
  11. 28-Dec-2020 18:27:35.557 严重 [http-nio-8080-exec-17] org.apache.catalina.core.StandardWrapperValve.invoke 在路径为/TomExam的上下文中,Servlet[jsp]的Servlet.service()引发了具有根本原因的异常无法为JSP编译类:
  12. 在生成的java文件中的第:[16]行发生错误:[/usr/local/apache-tomcat-8.5.61/work/Catalina/localhost/TomExam/org/apache/jsp/WebRoot/login_jsp.java]
  13. Only a type can be imported. com.tom.cache.ConfigCache resolves to a package
  14. JSP文件:[/WebRoot/login.jsp] 的第 [6] 行发生了一个错误
  15. ConfigCache cannot be resolved
  16. 3: <html xmlns="http://www.w3.org/1999/xhtml">
  17. 4: <head>
  18. 5: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. 6: <title><%=ConfigCache.getConfigByKey("sys_sitename") %> - 系统登陆</title>

localhost_access_log.YYYY-MM-DD.txt

localhost_access_log.2018-09-19.txt:这个是访问tomcat的日志,请求时间和资源,状态码都有记录。
溯源的时候,如果找到了时间切入点,则可以根据这个日志来进行溯源。

  1. [root@localhost logs]# head -n 100 localhost_access_log.2020-12-28.txt
  2. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET / HTTP/1.1" 200 11156
  3. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /tomcat.svg HTTP/1.1" 200 67795
  4. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /tomcat.css HTTP/1.1" 200 5542
  5. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /bg-nav.png HTTP/1.1" 200 1401
  6. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /asf-logo-wide.svg HTTP/1.1" 200 27235
  7. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /bg-upper.png HTTP/1.1" 200 3103
  8. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /bg-button.png HTTP/1.1" 200 713
  9. 127.0.0.1 - - [28/Dec/2020:18:08:10 +0800] "GET /bg-middle.png HTTP/1.1" 200 1918
  10. 127.0.0.1 - - [28/Dec/2020:18:08:12 +0800] "GET /TomExam/WebRoot/register.jsp HTTP/1.1" 404 729
  11. 192.168.15.107 - - [28/Dec/2020:18:22:23 +0800] "GET / HTTP/1.1" 500 44990
  12. 192.168.15.107 - - [28/Dec/2020:18:22:23 +0800] "GET /favicon.ico HTTP/1.1" 200 9662
  13. 192.168.15.107 - - [28/Dec/2020:18:22:43 +0800] "GET /netBank/index.jsp HTTP/1.1" 200 4532
  14. 192.168.15.107 - - [28/Dec/2020:18:22:52 +0800] "POST /user/user_login HTTP/1.1" 404 1404
  15. 127.0.0.1 - - [28/Dec/2020:18:23:01 +0800] "GET /www/netBank/left.jsp HTTP/1.1" 403 1461
  16. 192.168.15.107 - - [28/Dec/2020:18:23:53 +0800] "GET /ROOT/support_genuine.htm HTTP/1.1" 404 1404
  17. 192.168.15.107 - - [28/Dec/2020:18:25:50 +0800] "GET /ROOT/WEB-INF/views/index.jsp HTTP/1.1" 403 1461
  18. 192.168.15.107 - - [28/Dec/2020:18:26:07 +0800] "GET /ROOT/WEB-INF/views/head.jsp HTTP/1.1" 403 1461
  19. 192.168.15.107 - - [28/Dec/2020:18:26:18 +0800] "GET /ROOT/WEB-INF/views/login.jsp HTTP/1.1" 403 1461
  20. 192.168.15.107 - - [28/Dec/2020:18:27:35 +0800] "GET /TomExam/WebRoot/login.jsp HTTP/1.1" 500 3288
  21. 192.168.15.107 - - [28/Dec/2020:18:28:38 +0800] "GET /TomExam/WebRoot/index.jsp HTTP/1.1" 500 2775

host-manager.YYYY-MM-DD.log

估计是放tomcat的自带的manager项目的日志信息的
谷歌这样说:
host-manager and manager the logs of the related web applications.
主机管理器Webapp的日志
我这里是空的
image.png

manager.YYYY-MM-DD.log

这个是tomcat manager项目专有的日志文件.
image.png