aspose file tools*
The moose likes Other Application Frameworks and the fly likes log4j:WARN Please initialize the log4j system properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "log4j:WARN Please initialize the log4j system properly " Watch "log4j:WARN Please initialize the log4j system properly " New topic
Author

log4j:WARN Please initialize the log4j system properly

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Hi All,
I am trying to implement logger concept in my java application.

For testing purpose I am creating a Test.java file .I have added the log4j-1.2.9.jar.
I am not getting any compilation error. While executing the Test.java I am getting
Exception
log4j:WARN No appenders could be found for logger (Log4jTest.Test).
log4j:WARN Please initialize the log4j system properly.


Please suggest me how to fix this error.

Code
Test.java


log4j.properties


Thanks for your time.

Regards,
Sumanta Panda
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Is log4j.properties in the classpath when the program executes?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Nathan,
Its log4j.properties not in the classpath when the program executes.

Requesting you to please provide the solution how to fix it.

Thanks for your time.

Regards,
Sumanta Panda

yuvaraaj mohan
Greenhorn

Joined: Aug 17, 2009
Posts: 13
hi,

Which application server are you using?

Cheers,
Yuvaraj.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

If Tomcat 6, drop it in Tomcat's lib folder and it will apply for all web apps.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


sumanta ,

Before calling methods of log4j , the log4j configuration should be done. Either configured directly in code or through log4j.properties or xml file.



If you use log4j.properties , it should be in the classpath for the configuration to be used , make sure its copied to classes folder in-case of web application.
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Hi All,
I am using the logger concept in a Standalone java program with RAD tool.

My Folder Structure is::
D:\workspace_Log4j\Log4jTest
D:\workspace_Log4j\Log4jTest\src
D:\workspace_Log4j\Log4jTest\bin
D:\workspace_Log4j\Log4jTest\lib\ log4j-1.2.9.jar
D:\workspace_Log4j\Log4jTest\ log4j.properties

Please suggest me if my folder structure is wrong.

My doubt is how Test.java is knowing we are using log4j.properties file?Do we need to initialize the log4j.properties in my Test.java file?

How can i use log4j.properties in the classpath configuration ?

Thanks for your time.
Please suggest how i fix this error.
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Hi All,
This issue has been resolved after copied the log4j.properties in the src location D:\workspace_Log4j\Log4jTest\src\ log4j.properties .

Thanks to all.


Best Regards,
Sumanta Panda
Tcs
Chandra Mouli Kakara
Greenhorn

Joined: Mar 13, 2011
Posts: 3
Hi,

Please find the below steps to solve the issue

Issue :
log4j:WARN No appenders could be found for logger (com.app.MyLogger).
log4j:WARN Please initialize the log4j system properly.


Solution :
1)download log4j-1.2rc1-2002-04-16.jar file
2)Add the log4j-1.2rc1-2002-04-16.jar file to build path
3)create object private static org.apache.log4j.Logger log= Logger.getLogger(MyLogger.class);
4)once you run the Mylogger.java file system will automatically creates the log4j.properties file
5)find out the log4j.propertiesfile and replace the contents as per the requirements(mostly system will creates in bin directory)
6)if not find log4j.properties file create one new file in bin directory (/workspace/projectdirectory/bin/)
6)log4j.properties
log4j.rootLogger=debug, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%t %-5p %c{2} - %m%n



Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Any reason you are suggesting downloading an old release candidate version of log4j, rather than an official build?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j:WARN Please initialize the log4j system properly