?
Solved

Log4j JSP Warning Message

Posted on 2011-05-12
5
Medium Priority
?
649 Views
Last Modified: 2012-06-27
I'm using log4j in my Tomcat 5.5 web app.  I need to do basic logging.

Attached is the log4.properties file I placed in WEB-INF directory.  Logging works fine in catalina.out.

Problem is that when I redeploy the web app to Tomcat, I get the following message in catalina.out

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax)
log4j:WARN Please initialize the log4j system properly.

Should I ignore this warning?  Am I missing something?
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

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

Open in new window

String __jspName = this.getClass().getSimpleName().replaceAll("_", ".");

BasicConfigurator.configure();
Logger log = Logger.getLogger(this.getClass().getName());
log.info("BEGIN JSP "+__jspName);

Open in new window

0
Comment
Question by:lcor
  • 4
5 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 35749686
0
 
LVL 47

Accepted Solution

by:
for_yan earned 1600 total points
ID: 35749929
I think your  log4.properties file should be in
WEB-INF/classes

Is it places in there?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35749955
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35750030
Even though the last link did not have accepted by the asker solution
there are some possibly reasonable suggestions:

In particular in the lst trail there is suggestuion to add this to log4.properties:
--------------------
log4j.logger.org.apache.commons.digester.Digester.sax=R

question about adding appender
-------------------
I can't see that you add the appender to the logger?

yourLogger.addAppender(yourAppender);
--------------------------
and also suggestion not to use properties at all like that:
-------------------------
static Logger               eventLogger         = Logger.getLogger("MyPackage.Eventlogger");

ConsoleAppender m_EventConsoleAppender  = new ConsoleAppender(new PatternLayout("[%d] %-5p - %m%n"), ConsoleAppender.SYSTEM_OUT);

m_EventConsoleAppender.activateOptions();
eventLogger.addAppender(m_EventConsoleAppender);
------------------

0
 
LVL 92

Assisted Solution

by:objects
objects earned 400 total points
ID: 35751239
> Attached is the log4.properties file I placed in WEB-INF directory.  Logging works fine in catalina.out.

the warning is because it cannot find log4j.properties
it should be in WEB-INF/classes
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question