Log4J/JCL questions

  • Thread starter Joona I Palaste
  • Start date
J

Joona I Palaste

I'm trying to redesign our application's logging system to use Log4J
and/or JCL instead of using our own proprietary implementation. I have
some general questions:

1) I would want the system to always use Log4J as the actual
implementation of the logger. Should I be bothering with JCL at all, or
instead using the Log4J classes and APIs directly?

2) If the answer to 1 is "I should be bothering with JCL", is there any
way to *force* the JCL LogFactory class's getLog(String) or
getLog(Class) methods to always give me a Log4JLogger?

3) Is there any simple *and efficient* way to automatically determine
the category and/or class name for the Log4J logger? I could always do
this:

package com.mycompany.main;
import org.apache.commons.logging.*;
public class Foobar {
Log log = LogFactory.getLog(Foobar.class);
/* or */
Log log = LogFactory.getLog("Foobar");
}

but is there any way to do something like this?:

package com.mycompany.main;
import com.mycompany.logging.*;
import org.apache.commons.logging.*;
public class Foobar {
Log log = MyLogging.getLog();
}

where MyLogging is something like this:

package com.mycompany.logging;
import org.apache.commons.logging.*;
public class MyLogging {
public static Log getLog() {
Class caller = /* somehow dynamically determine the class of the
calling object */;
return LogFactory.getLog(caller);
}
}

I suspect there isn't, at least not *effectively*, but it's worth asking
anyway.

Thanks a lot for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top