View Tomcat log files in a browser

I need to somehow expose the Tomcat log files in the browser. I know that this is not safe, but that is what is required.

I considered creating a hard link from a log location, for example tomcat/webapps/ROOT/html/catalina.out β†’ mydir/logs/catalina.out , but I don't think this is a good solution (although it works). Is there a way to display Tomcat log files in a browser?

+6
source share
1 answer

This modification to distribution configurations will expose Tomcat logs over HTTP through Tomcat DefaultServlet services. Confirmed by Tomcat 7.0.56, 8.0.24 distributions.

For this example, the Tomcat canonical distribution is provided for unpacking in / opt / tomcat.

In /opt/tomcat/conf/Catalina/localhost create a logs.xml file with this content:

<Context override = "true" docBase = "/ opt / tomcat / logs" path = "/ logs" />

Restart Tomcat. Find the log file that you know exists, for example

  • local: 8080 / logs /catalina.out

If you also want to see a list of logs, suggest this additional configuration change.

Edit /opt/tomcat/conf/web.xml . If the listings parameter is configured, enable it by setting it to true :

...
& L; servlet>
...
<INIT pairs>
<pairs name-> lists <vapor-name and / GT;
<pair-value> <strong> true </pair-value>
</ Init pairs>
...

Restart tomcat for the change to take effect. Expect to see a list of log files as interactive links when conducting this test in a browser

  • local: 8080 / magazines /

These options are probably undesirable for some production environments due to security issues or performance / resource utilization.

In some ways, rephrasing this item: The easiest way to serve static data outside the application server in a Java web application

Read more (at the ragged edges of this question)

And always useful documents

+8
source

Source: https://habr.com/ru/post/952249/


All Articles