Showing posts with label Log4j. Show all posts
Showing posts with label Log4j. Show all posts

Tuesday, April 29, 2014

Using JS Test Runner with slf4j-log4j12

Hello.

If you've tried using JS Test Runner to integrate your QUnit JavaScript unit tests with Maven you may have noticed that JS Test Runner has a transitive dependency to slf4j-jcl (Simple Logging Facade for Java with Jakarta Commons Logging bridge).  This is supposed to be easily fixed by using Maven's dependency exclusions but for some unknown reason this did not work for my project.  This resulted in two slf4j appenders being present at the same time, causing a warning from slf4j ("Multiple bindings were found on the class path").  A warning usually isn't too bad of a problem but it caused the Google App Engine to crash locally, making it a blocking issue.  I tried manually changing the POM file the Right Way by cloning the Git repository and trying to run `mvn install` on an incremented version of it, but it required GPG and that failed on my Windows 64bit machine ("Sorry, no terminal at all requested - can't get input").  So, out of desperation I "monkey-patched" the current POM (1.0.2) manually to use slf4j-log4j12 (like the rest of my project) instead of slf4j-jcl.  This has been working beautifully... but is a blatant hack.

In Summary, if you're having problems with JS Test Runner vis a vis logging you want to manually edit the POM file in your local repository (and document it in your project).

Monday, December 19, 2011

Valhalla Koan: Logging Without Logging

OK, this isn't really a koan, because there is an answer.  The more mundane version of the question is, how do you make log statements to diagnose why your favorite logging framework isn't working.

Just as parents can learn from their children, those close to mastery can learn from the neophytes, System.out.println is usually acceptable (you're web-container may vary).

If you're using WebLogic 11g, their logging documentation can be just as confusing as a koan.  Fortunately, as a part-time hipster I'm really into their earlier work (i.e. their prior documentation actually makes sense).

So, to get to the point, if you want to use the WebLogic logging before you initialize your favorite like (like Log4j) you can:

  1. Use the simpler WebLogic APIs for logging until your main logger is working.
  2. You may have to have your WebLogic server use more logging statements (mine was set to only WARNs and above but all of my logging statements were INFO until I changed it).  You can do that by:
    1. Logging into the WebLogic Console.
    2. Going to Environment -> Servers.
    3. Select the server you want.
    4. Click on the Logging tab.
    5. Expand the Advanced section.
    6. Turning everything to DEBUG or TRACE. 
    7. Save your changes.
    8. Restart the server.
    9. Finally, redeploy your application.
  3. Then you can trigger the early logging statements and view them in the WebLogic Server Administration Console.
If you're familiar with Oracle and WebLogic products, you appreciate how this is as simple and straightforward as it gets.