Link to home
Start Free TrialLog in
Avatar of bhomass
bhomass

asked on

can't get log4j to start in tomcat6

I followed the instructions in
http://tomcat.apache.org/tomcat-6.0-doc/logging.html

tried using ${catalina.home}/lib and ${catalina.home}/shared/lib for the jar and .properties file.

log4j.properties looks like this
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=${catalina.home}/logs/tomcat.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

#log4j.logger.org.hibernate=error
log4j.logger.org.hibernate=error

tomcat.log file is never created. any body see anything wrong?
Avatar of blackfrancis75
blackfrancis75

change

log4j.rootLogger=warn, stdout

to


log4j.rootLogger=warn,stdout,file
Avatar of bhomass

ASKER

I tried that,

I also tried using explicit file path,

then i tried moving the properties file and log4j lib to the application lib dir.

in all case i can not get the tomcat.log file to be generated!

what else can be wrong?

it all works inside eclipse. is there some additional thing I need to do in deployment to kick start log4j?
whereabouts in your project/source tree have you placed log4j.properties ?  it should be in the root of your /src directory, and Eclipse should copy it into WEB-INF/classes when it compiles.  Check that this is working.  Most important is that a copy of the file ends up in WEB-INF/classes
Avatar of bhomass

ASKER

it is there for sure.
Where in your code have you put loging statements?  Are you logging anything during statup of your app?
Also, are there any exceptions in Tomcat's own logs?
Avatar of bhomass

ASKER

I have Logger.getLogger(class) all over the place. these produce good output in eclipse.

nothing notable in tomcat logs.
I'm a little confused.  What do you mean by getting logging statements 'in Eclipse'?  Isn't this a web-app?
Do you mean the Console logger is working, but not the File logger?
ASKER CERTIFIED SOLUTION
Avatar of blackfrancis75
blackfrancis75

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if ${catalina.home} can't be determined, the path will be determines relative to the Eclipse installation directory - so try making (or checking) a /logs directory in the Eclipse installation directory
Avatar of bhomass

ASKER

I switched to logback. it worked instantly.

although I still don't know what went wrong with my log4j set up, I would like to award you the points for staying with me.
Avatar of bhomass

ASKER

real bug still unknown