File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes No logs from log4J on Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "No logs from log4J on Server" Watch "No logs from log4J on Server" New topic

No logs from log4J on Server

Lukas Benberg
Ranch Hand

Joined: Jan 03, 2007
Posts: 45
Hi all,
I use slf4j and log4j in Tomcat6. Locally (in my Eclipse IDE), I get the desired logs logged to the console, with my current log4j configuration. On server (Ubuntu 9.10), I assumed that ConsoleAppender logs would go to the the /var/log/tomcat6/catalina.2009-xx-xx.log files. But I don't get any application logs there. Neither do I get any warnings concerning log4j initialization at Tomcat startup.

I also configured a FileAppender, but also no logs from that in /var/log/tomcat6/ . Is something wrong with my configuration? Where should I find the file "myapp.log" created by FileAppender?


### direct log messages to stdout ###
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct log messages to file myapp.log ###
log4j.appender.file= org.apache.log4j.FileAppender
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### Set root logger ###
log4j.rootLogger=ERROR, stdout, file

### Set log levels for packages ###, stdout, file, stdout, file
log4j.logger.calculator=DEBUG, stdout, file

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

You used a relative path in your configuration, and no doubt you made an incorrect assumption about what directory it is relative to. (Did you assume it would be relative to your web application in some way? Why would Tomcat make it relative to only one of the many web applications it could be running simultaneously?) Use an absolute path instead.
Lukas Benberg
Ranch Hand

Joined: Jan 03, 2007
Posts: 45
Well, I assumed the Tomcat log directory to be the default directory also for its applications. It works with an absolute path (the log directory must be writable for Tomcat user).
I agree. Here's the link:
subject: No logs from log4J on Server
It's not a secret anymore!