Boss let me in the NGINX+TOMCAT environment to meet the following requirements:
Nginx points to a page that contains various log files from the Tomcat server
When you click a log file, the contents of the log file are displayed
Pre-operation Preparation
Install and build the Nginx,tomcat.
Log file
We know that Tomcat's log files are in the/tomcat/logs directory
Lscatalina.2016-03-04.log Host-manager.2016-03-04.log Localhost.2016-03-05.log localhost_access_log.2016-03-07 . Txtcatalina.2016-03-05.log Host-manager.2016-03-05.log Localhost.2016-03-07.log Manager.2016-03-04.logcatalin A.2016-03-07.log Host-manager.2016-03-07.log Localhost_access_ Log.2016-03-04.txtmanager.2016-03-05.logcatalina.out Localhost.2016-03-04.log localhost_access_log.2016-03 -05.txtmanager.2016-03-07.log
For example, we want to see in real time on the page
Catalina.out Localhost.2016-03-04.log Manager.2016-03-07.log
These 3 log files
Then you can do the following:
Cd/usr/local/tomcat/webapps/logsln/usr/local/tomcat/logs/catalina.out Localhost.2016-03-04.log Manager.2016-03-07.log aaa.log bbb.log Ccc.log #将需要的日志做上硬链接
Two JSP pages
Create a menu of JSP directory pages below
Three set in Nginx
Forward the Nginx request directly to the JSP page we just created, then we can directly access the log Directory page we need to view.
server{Listen 80; server_name localhost; Index index.html index.htm index.php; Root/usr/local/tomcat/logs; Access_log/usr/local/tomcat/logs/catalina.out; Location/{Proxy_pass #这个是该页面的访问路径}}
Restart Nginx Service
Summary: Then, you can use the Nginx forwarding function, directly view the log directory, improve security.
Use Nginx to specify access to the Tomcat log