Menu

log4j configuration how to?

Anonymous
2010-10-20
2015-12-16
  • Anonymous

    Anonymous - 2010-10-20

    I'm having trouble getting log4j to load my log4j.xml configuration file. It keeps loading some other log4j configuration I'm not aware of (having a lot of libraries in my one-jar).

    The release notes for 0.97 say something about "Support for Log4j configuration" but I have not been able to find any documentation about how that should work?

    Can anybody point me in the right direction?
    Thanks!
    - mike

     
  • P. Simon Tuffs

    P. Simon Tuffs - 2010-10-20

    Hello:

    generic log4j diagnosis is available by setting -Dlog4j.debug=true on the command line: log4j will dump the source of its configuration properties and this should help you diagnose your immediate problems.

    Regarding documentation, you're right there is no specific documentation, but this page: http://one-jar.sourceforge.net/index.php?page=downloads&file=build refers to an example (one-jar-log4j) which shows how to build and run a log4j project.  You can download it through this link (also on the same documentation page) http://one-jar.cvs.sourceforge.net/viewvc/one-jar/?pathrev=version_0_9_7_RC11

    Please continue this discussion with questions to help improve the documentation.

    Thanks!

    Simon.

     
  • Anonymous

    Anonymous - 2010-10-21

    Thanks for pointing me in the right direction! In the end, this wasn't a One-Jar issue but I'll post my resolution here for reference :-)

    I tried enabling log4j debugging by setting the system property -Dlog4j.debug=true, but strangely, that didn't affect the output I was getting… That gave me the clue that maybe it wasn't even Log4j output I was seeing.

    In fact, the logging came out of the Spring Framework, which, when no log4j is found in the classpath, magically switches to java.util.logging, and that's what I was getting. No wonder my log4j.xml configuration was never used, no matter where I put it. The solution, of course, was to include log4j in the one-jar and now it even picks the right configuration immediately.

    I still think a small chapter in one-jar's supported frameworks documentation would be a good idea (maybe you could even include the hint -for dummies like me- that log4j must be included in the one-jar for it to work ;-)).

    But thanks a lot for your quick support!
    Best regards,
    Mike

     
  • Djangofan

    Djangofan - 2011-07-21

    Can one-jar load the log4j.properties from within the executable jar?  If so, how?

     
  • Anonymous

    Anonymous - 2011-09-10

    Thanks for sharing your pain, I have also been bitten by silent fallback to java.util.logging, is often known as JULI.  JULI is one of those NIH cases, why Sun didn't integrate log4j like they integrated other apache projects is a mystery to me. Integrate after cleaning up it's thread model, that is.

    I have been working to document frameworks, e.g. spring & guice: http://one-jar.sourceforge.net/index.php?page=frameworks&file=frameworks, but not their transitive depencencies such as logging. When I next get time to work One-JAR I will try to doc this.

    I would appreciate help such as yours in this effort.

     
    • Ken Hancock

      Ken Hancock - 2015-12-16

      Disregard...works fine, I had a log4j.xml configuration error.

       

      Last edit: Ken Hancock 2015-12-16

Log in to post a comment.