Use Nginx to specify access to the Tomcat log

Source: Internet
Author: User

Boss let me in the NGINX+TOMCAT environment to meet the following requirements:

    1. Nginx points to a page that contains various log files from the Tomcat server

    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.