Configure 4j logging for a GWT application in Eclipse

Can someone help me configure log 4j. I am using eclipse and the application is a gwt application. Whenever I launch a web application, it displays

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

I put the log4j.propeties file in the 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 anyone help?

+4
source share
3 answers

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

+5
source

You need to make sure that log4j.properties is found in the classpath of your web application. A typical place for this is WEB-INF / classes. If you put your file under src , Eclipse can deploy it to WEB-INF/classes , but it's worth checking it twice.

You also need to add a registrar configuration to determine which packages / classes should be registered in the application. For instance.

 log4j.logger.org.apache=WARN 
+4
source

Run tomcat with -Dlog4j.debug = true and you will see what log4j does during initialization.

Where is your log44j located? In the / WEB-INF / lib / section, or somewhere in the path to the server class? The error message refers to the class that belongs to tomcat, and not to your project. Maybe tomcat itself is not configured correctly with log4j.

+3
source

Source: https://habr.com/ru/post/1340429/


All Articles