Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where go my logging files of my webapp on a linux Tomcat 7 installation?

I currently develop a simple web app using Eclipse and a local Tomcat 7 server. I configured Eclipse so I can start the Tomcat 7 right out of my IDE - not much magic here.

In my web app, I use SLF4J with Logback, which looks like this in a service class:

public class MyServiceImpl implements MyService
{
  private static Logger logger = LoggerFactory.getLogger( MyServiceImpl.class );

  public void doSomeStuff()
  {
      logger.info( "Doing some stuff" );
  }
}

My logging is configured this way:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>log/MyTestWebApp.%d.log.zip</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="com.test" level="WARN" />

    <root level="WARN">
        <appender-ref ref="fileAppender" />
    </root>

</configuration>

When I start my web app and so the local Tomcat 7 server, the logging output goes to

./log/MyTestWebApp.log

as expected, where the current directory is that where my web app is (for example, where my Maven pom.xml is).

When I start my web app on a remote linux machine, I can't find any "MyTestWebApp.log" file, not in directoy of my web app, nor in the Tomcat7-root directory.

So my simple question is, where do those logs go and where is my "MyTestWebApp.log" file respectively?

Thanks a lot for your help!

like image 497
It's Leto Avatar asked Aug 22 '11 21:08

It's Leto


People also ask

Where the log files are stored in Tomcat?

The main Apache Tomcat configuration file is at /opt/bitnami/tomcat/conf/server. xml. Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/tomcat/logs directory.

Where are Tomcat logs stored Linux?

This log file exists on the computer hosting the Tomcat server instance. Each server instance contains its own Catalina. out log file. This file is located in the logs directory below the Tomcat root directory.

Which folder of Tomcat do you have to put your web application?

Simply put, web applications are placed under $CATALINA_HOME\webapps, where $CATALINA_HOME is the Tomcat's installation directory. The context path refers to the location relative to the server's address which represents the name of the web application.


2 Answers

The log file is inside the starting directory of Tomcat. You can get this directory with this command:

grep -az "\bPWD" /proc/TOMCAT_PID/environ
like image 79
palacsint Avatar answered Sep 23 '22 16:09

palacsint


Have you checked the permissions inside your tomcat7 directory? I.e. who owns /var/lib/tomcat7 ? Sometimes an installation will make this directory owned by root, not allowing the Tomcat7 user to create a 'log' directory in there in the first place.

To fix it, simply

sudo chown tomcat7:tomcat7 /var/lib/tomcat7

Hope it helps, Sekm

like image 34
Sekm Avatar answered Sep 25 '22 16:09

Sekm