Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

moving from log4j 1.1.1 -> 1.2.8

 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic