integrating commons logging with Log4j

Hello

I am using spring framework and trying to implement commons logging integrated with Log4j. I have used interceptors and they are working fine with System.out.println. Now I need to use Log4j instead of SOPs. Please Help.

Gurpreet Singh

[260 byte] By [gurpreet.sainia] at [2007-11-27 11:01:53]
# 1

If you use the apache commons API, then it will automatically pick up log4j if it's on the class path. Otherwise it will use the logger built into the standard library.

The tiresome part is actually getting the configuration file set up and accessed. All you need in the code is something like:

public class A {

private static Log log = LogFactory.getLog(A.class);

...

log.info("This is a log message");

}

You'll generally need a -D parameter to set the logger to point at the appropriate configuration file.

If you use the standard libraray logger then you can actually change the logger settings dynamically with jconsole.

malcolmmca at 2007-7-29 12:39:42 > top of Java-index,Java Essentials,Java Programming...
# 2

thanks, that is done ..

gurpreet.sainia at 2007-7-29 12:39:42 > top of Java-index,Java Essentials,Java Programming...