Link to home
Start Free TrialLog in
Avatar of odumbe
odumbe

asked on

Log4j

I have written a simple Java class and inlcuded log4j.jar in the classpath.

In log4j.properties I have written
log4j.rootCategory=DEBUG, C:\\logger.txt
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout

and in my class I have written

import org.apache.log4j.*;

public class myclass {
      static Logger logger = Logger.getLogger(myclass .class);

public static void main(String[] args) {
logger.debug("111111111111111111111111111");
}

But I am getting the following error

log4j:ERROR Could not find value for key log4j.appender.C:\logger.txt
log4j:ERROR Could not instantiate appender named "C:\logger.txt".
log4j:WARN No appenders could be found for logger (com.myclass).
log4j:WARN Please initialize the log4j system properly.

Also nothing gets written to logger.txt
How can I fix this.
Avatar of odumbe
odumbe

ASKER

Also tried chaging
static Logger logger = Logger.getLogger(myclass .class);

to
static Logger logger = Logger.getLogger(com.myclass .class);

where com is the package name but still same problem.
ASKER CERTIFIED SOLUTION
Avatar of elfe69
elfe69
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial