MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
dabeamer42
Post subject: log4j properties not found  PostPosted: Mar 07, 2011 - 11:14 PM



Joined: Jan 22, 2009
Posts: 5

Error is log4j:WARN No appenders could be found for logger (DbTester1).
log4j:WARN Please initialize the log4j system properly.

Environment: ME 7.5
Java 1.6
JDBC - ojdbc14.jar & sqljdbc.jar
NO Hibernate
log4j.1.2.16
slf4j
jdbcdslog

I have a plain-vanilla procedural Java program that reads one database via JDBC and writes another. Still in test mode, I'm just running the program from inside ME, with misc. output going to the Console.

I'm trying to add logging to the JDBC calls with jdbcdslog. I've added slf4j and log4j jars to the Build Path. I understand that there has to be a log4j.properties file, but I don't know where to put it. I have added the following code to my program to try to find out what's going on:


Code:
       java.util.Properties prop = System.getProperties();
       prop.setProperty("log4j.debug", "true");
...
Turning on the log4j.debug property gives me the following output on the Console:

log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@1ba34f2.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@1ba34f2 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@1ba34f2.
log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@1ba34f2 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [null].

(then the "log4j:WARN No appenders could be found for logger (DbTester1).
log4j:WARN Please initialize the log4j system properly." lines print.)

How do I tell ME where to find the log4j.properties file?
 
 View user's profile Send private message  
Reply with quote Back to top
support-joy
Post subject: RE: log4j properties not found  PostPosted: Mar 10, 2011 - 06:56 PM
Registered Member
Registered Member


Joined: Feb 03, 2009
Posts: 3442

dabeamer42,

Have you added log4j relevant jar file to your build path? You need to add the log4j.properties file on top of your /src directory so it gets built out to your /classes directory, log4j should find and use it then.

You can refer - http://www.coderanch.com/t/458568/oa/log-WARN-Please-initialize-log and http://www.laliluna.de/articles/first-hibernate-example-tutorial.html

_________________
Joy
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
dabeamer42
Post subject: log4j  PostPosted: Mar 10, 2011 - 07:11 PM



Joined: Jan 22, 2009
Posts: 5

Yes, I've got all the jars on the build path. Neither of those examples were helpful, because I'm not using Hibernate or Tomcat or anything like that -- this is a command-line app.

I tried a couple other things, and finally got log4j to recognize the log4j.properties file by putting it in the bin directory. (Other posts suggest the src dir, the classpath, etc.)

So next I'll move on to getting log4j to actually write to a file. At least the first part is solved...
 
 View user's profile Send private message  
Reply with quote Back to top
dabeamer42
Post subject: log4j  PostPosted: Mar 10, 2011 - 07:17 PM



Joined: Jan 22, 2009
Posts: 5

Yes, I've got all the jars on the build path. Neither of those examples were helpful, because I'm not using Hibernate or Tomcat or anything like that -- this is a command-line app.

I tried a couple other things, and finally got log4j to recognize the log4j.properties file by manually putting it in the bin directory. (Other posts suggest the src dir, the classpath, etc.)

So next I'll move on to getting log4j to actually write to a file. At least the first part is solved...
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits