Noor
Noor

Reputation: 20130

Configuring Log 4j for GWT Application in Eclipse

Can someone help me configuring log 4j. I am using eclipse and the application is a gwt app. Whenever, i'm starting web app, it is displaying

log4j:WARN No appenders could be found for logger (org.apache.jasper.compiler.JspRuntimeContext).
log4j:WARN Please initialize the log4j system properly.

I have placed log4j.propeties file in src of the gwt application. The log4j.propeties file contains:

# Set root logger level to DEBUG and its only appender to Appender1.
log4j.rootLogger=INFO, Appender1,Appender2

# Appender1 is set to be a ConsoleAppender.
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender2=org.apache.log4j.RollingFileAppender
log4j.appender.Appender2.File=sample.log


# Appender2 uses PatternLayout.
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Can someone help??

Upvotes: 4

Views: 6441

Answers (3)

Chris Lercher
Chris Lercher

Reputation: 37778

If you really named it
"log4j.propeties" instead of
"log4j.properties", then this may be the reason.

Upvotes: 5

Yoni
Yoni

Reputation: 10321

Start tomcat with -Dlog4j.debug=true, and you'll see what log4j is doing during initialization.

Where is your log4j jar located? Under /WEB-INF/lib/, or somewhere in the classpath of the server? The error message refers to a class that belongs to tomcat, not to your project. It could be that tomcat itself is not configured properly with log4j.

Upvotes: 3

Péter Török
Péter Török

Reputation: 116246

You need to ensure that log4j.properties is found on the classpath of your web app. A typical place for it is WEB-INF/classes. If you put your file under src, Eclipse may deploy it into WEB-INF/classes, but it is worth double checking.

You also need to add logger configuration to determine which packages/classes are to log to which appender. E.g.

log4j.logger.org.apache=WARN

Upvotes: 4

Related Questions