This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Open Source Projects and the fly likes moving from log4j 1.1.1 -> 1.2.8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "moving from log4j 1.1.1 -> 1.2.8" Watch "moving from log4j 1.1.1 -> 1.2.8" New topic
Author

moving from log4j 1.1.1 -> 1.2.8

Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Hi,

We are facing problem in changes to be done for running our code on 1.2.8 version. Earlier it was working for 1.1.1 version.

In 1.1.1 version, Category class instance is initilized and log4j.properties is set as Category.DEFAULT_CONFIGURATION_FILE. (But we are getting this issue even in test code. We put log4j.properties file in classpath but still is says:
log4j:ERROR No appenders could be found for category (log4j111.PlanetDiameters111).
log4j:ERROR Please initialize the log4j system properly.

In 1.2.8, Logger is initilized as


Can someone share thoughts on what could be missing here/or need to be done for getting Category instance replaced with Logger.

Codes are:
For 1.1.1


For 1.2.8

log4j.properties
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

log4j:ERROR No appenders could be found for category (log4j111.PlanetDiameters111).
log4j:ERROR Please initialize the log4j system properly.


When you use Logger.getLogger, log4j searches for the configuration file (either log4j.properties or log4j.xml) in the classpath. If it doesn't find this file then it prints out the message you are seeing.

Your code with 1.1.1 was working because you programatically set the log4j configuration file location:



Make sure that you are placing the log4j.properties in the classpath. You can pass -Dlog4j.debug as a JVM parameter to see where log4j is trying to pickup the file from.


[My Blog] [JavaRanch Journal]
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Hi Jai,

I have set path to log4j.properties in classpath as D:\JavaWork\workingjava\src\log4j111\log4j.properties;

On providing that debug argument, It displays:


Can you help.. why its not picking from classpath?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Originally posted by Raminder Singh:
I have set path to log4j.properties in classpath as D:\JavaWork\workingjava\src\log4j111\log4j.properties;



Is this an web application? If yes, then the CLASSPATH environment variable will not be used.
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
yes. it is a web apps. Whats resolution for this? how to make sure.. log4j.properties is set properly and geting passed to classloader.??
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Try placing it in the WEB-INF/classes folder or probably at the root of the WAR file.
[ May 28, 2008: Message edited by: Jaikiran Pai ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: moving from log4j 1.1.1 -> 1.2.8