• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic