RSS Feed Subscribe to RSS Feed

 

SLF4J & Logback is the new commons-logging & log4j

Interesting post on which logging framework to choose from the logging mess.

I still default to log4j, but it sounds like logback (as the new alternative to log4j), wrapped by SLF4J (as the new alternative to commons logging) is the way forward. Both are written by Ceki Gülcü (blog), the original log4j author.

Tags: , , ,

Add log4j logging for a unit test in IntelliJ

In IntelliJ

  • Click: Run -> Edit Configuration
  • Select your test configuration (or add a new one)
  • In VM parameters, add
    -Dlog4j.configuration=file:/C:/dev/config/log4j.xml
    (Or wherever your log4j properties file is)

That’s it. The test should now run with log4j logging (although obviously you need to have the necessary log4j jars available).
This example uses a windows file format, but will work equally well with *nix.

I use this approach for turning on MyBatis logging for individual tests. See here for a basic setup of a log4j.xml file to enable logging with MyBatis.

Tags: , , , ,