This is my log4j.xml and I want to create a log file wws.log either in a
folder where folder path = AE_HOME/logs/ where AE_HOME = "C:/AE/" and
AE_HOME is set as a system variable by another program already.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<layout class="org.apache.log4j.PatternLayout">
</layout>
</appender>
I also tried using env:AE_HOME in the file path but still I dont find the
log file getting generated anywhere. I tried hard coding the path too, but
still no log file. I have permission to write in the C drive so that's not
an issue.
This is where the logger is being setup in the ServletInit class:
//initialize log4j
String log4jConfig =
event.getServletContext().getInitParameter("log4j-config"); // log4jConfig =
"WEB-INF\log4j.xml"
if (log4jConfig == null){
System.err.println("No log4j-config init param, initializing log4j
with BasicConfigurator");
BasicConfigurator.configure();
}else {
String webAppPath = event.getServletContext().getRealPath("/");
String log4jProp = webAppPath + log4jConfig;
File log4jConfigFile = new File(log4jProp);
if (log4jConfigFile.exists()) {
System.out.println("Initializing log4j with: " + log4jProp);
DOMConfigurator.configure(log4jProp);
} else {
System.err.println(log4jProp + " file not found, initializing
log4j with BasicConfigurator");
BasicConfigurator.configure();
}
}
System.out.println("log4j configured properly");
logger = Logger.getLogger(ServletInit.class.getName());
logger.info("INITIALIZED APPLICATION");
Is there something I am doing wrong?
Please advise.
--
View this message in context:
http://apache-logging.6191.n7.nabble.com/log4j-log-file-not-created-tp54471.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]