Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 951
Noor Avatar asked Dec 16 '22 17:12

Noor


2 Answers

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

like image 93
Chris Lercher Avatar answered Dec 28 '22 07:12

Chris Lercher


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
like image 34
Péter Török Avatar answered Dec 28 '22 08:12

Péter Török