aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j says: log4j:WARN Please initialize the log4j system properly. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j says: log4j:WARN Please initialize the log4j system properly." Watch "log4j says: log4j:WARN Please initialize the log4j system properly." New topic
Author

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

andres martin
Greenhorn

Joined: Jun 20, 2012
Posts: 1
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j says: log4j:WARN Please initialize the log4j system properly.