- This topic has 3 replies, 2 voices, and was last updated 13 years, 8 months ago by David.
-
AuthorPosts
-
DavidMemberError 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
jdbcdslogI 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:
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?
support-joyMemberdabeamer42,
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
DavidMemberYes, 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…
DavidMemberYes, 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…
-
AuthorPosts