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.a pache.log4 j.ConsoleA ppender
log4j.appender.dest1.layou t=org.apac he.log4j.P atternLayo ut
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("111111111111 1111111111 11111");
}
But I am getting the following error
log4j:ERROR Could not find value for key log4j.appender.C:\logger.t xt
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.
In log4j.properties I have written
log4j.rootCategory=DEBUG, C:\\logger.txt
log4j.appender.dest1=org.a
log4j.appender.dest1.layou
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("111111111111
}
But I am getting the following error
log4j:ERROR Could not find value for key log4j.appender.C:\logger.t
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
static Logger logger = Logger.getLogger(myclass .class);
to
static Logger logger = Logger.getLogger(com.mycla
where com is the package name but still same problem.