Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j says: log4j:WARN Please initialize the log4j system properly.

 
andres martin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I am trying to log information of my application.
I am using Loj4j and I see this tutorial: http://www.laliluna.de/articles/posts/log4j-tutorial.html

The problem is when I run the servlet without any log4j code says:

log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog).
log4j:WARN Please initialize the log4j system properly.
20/06/2012 08:14:45 PM org.apache.catalina.core.StandardService start

The code in a JAVA class(it is not a Servlet) to save in a log file is:

import org.apache.log4j.Logger;

private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ConexionPL.class);

Public void method()
{
log.trace("mesg");
}

The log4j.properties is in the root of the project(inside the SRC folder)
Here is the log4j.properties file:
# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.

log4j.rootLogger=ERROR,INFO,A1,file

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c{1}:%L - %m%n

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=5000KB
log4j.appender.file.maxBackupIndex=20
log4j.appender.file.File=/u01/tomcat/logs/FOLDER/FILE.log
log4j.appender.file.threshold=ERROR
log4j.appender.file.threshold=INFO
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c{1}:%L - %m%n

The strage here is that the fode in the JAVA class is never executed, right? I don´t understand why is the exception.
Any help?

Please let me know if you have any questions, and sorry for my english.

BR,
Andrés.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andres,
Welcome to CodeRanch!

In that example, the property file is set up to ERROR (the most stringent level of logging), but the code only logs on a trace level. It shouldn't log.

As you note, it is even getting there. Not being able to configure logging looks like is being treated as a fatal error so you aren't getting to the method. Do you have the log4j property file in your path?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic