开发者

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
lo开发者_运维知识库g4j.appender.Appender2.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Can someone help??


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜