noe wrote:
> Hi People,
> Anybody can help me with the below problem it is been days that i
> couldn't solve it.I really need some help! Thanks...
>
>
> org.apache.commons.logging.LogConfigurationException:
> java.lang.NullPointerException
> at
> org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:558)
> at
> org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:355)
> at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:409)
> at mankana.<init>(mankana.java:39)
> at mankana.main(mankana.java:98)
> Caused by: java.lang.NullPointerException
> at
> org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:543)
See <http://jakarta.apache.org/commons/logging/guide.html>
Commons logging is a wrapper around a number of possible different
logging systems, the most popular two are Log4J and the
java.util.logging.* classes in Java 1.4. Beepcore-Java uses
commons-logging so that folks using it can get beepcore-j to log using
their application's logging system, rather than forcing you to use
beepcore-j's logging system.
In your specific case, I cannot tell exactly why you are getting
NullPointerExceptions. But, I suggest you put the log4j
(<http://logging.apache.org/log4j/docs/>) package in your classpath, as
that is the most natural fit for commons-logging.
I will admit that figuring out how to configure commons-logging to do
exactly what you want can be confusing. The technique that has worked
best for me is to configure log4j before any of the commons-logging code
gets called. (Actually, when using log4j, I don't think you need to
configure it before the commons-logging stuff is called, but if you are
going to use a different logging system, you need to set that up first,
I believe).
For example:
public static void main(String[] args)
{
...
BasicConfigurator.configure();
// manually set the logging level to debug.
Logger rootLogger = Logger.getRootLogger();
rootLogger.setLevel(Level.DEBUG);
Log log = LogFactory.getLog(YourClass.class);
log.debug("debug logging turned on");
}
--
David Blacka <da...@ve...>
Sr. Engineer VeriSign Applied Research
|