5

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!

palacsint
  • 28,416
  • 10
  • 82
  • 109
It's Leto
  • 968
  • 4
  • 17
  • 25
  • 1
    if it works on your local machine but not remote, then you might want to check the privilege of the file, folder etc. – Will Aug 24 '11 at 00:36
  • Thanks for your answer, please see my comment below to palacsint's post, I found my logfile in the "Tomcat/bin/log/*" directory. – It's Leto Sep 18 '11 at 07:52

2 Answers2

4

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
palacsint
  • 28,416
  • 10
  • 82
  • 109
  • Thanks for your answer. I found my logfile in my "Tomcat/bin/log/*" directory. Well, I don't think this is a correct path for log files :) Is there a common approach how to configure the system, so logfiles are going into the right place (what ever this is)? – It's Leto Sep 18 '11 at 07:52
  • 2
    As I see there are two ways: set absolute paths in your logback.xml or make sure that Tomcat is always started from the proper directory. I usually use absolute paths and generate production wars with a maven profile which do resource filtering on the logback.xml and put the absolute paths in it. – palacsint Sep 18 '11 at 09:39
3

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

Sekm
  • 1,658
  • 13
  • 22