facebook

log4j properties not found

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #315047 Reply

    David
    Member

    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:

            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?

    #315125 Reply

    support-joy
    Member

    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

    #315126 Reply

    David
    Member

    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…

    #315127 Reply

    David
    Member

    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…

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: log4j properties not found

You must be logged in to post in the forum log in