logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coderbrat <knprathyu...@gmail.com>
Subject log4j log file not created
Date Mon, 06 Apr 2015 18:58:26 GMT
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 &quot;log4j.dtd&quot;>
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
        <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
            <layout class="org.apache.log4j.PatternLayout">

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 =
    if (log4jConfig == null){
        System.err.println("No log4j-config init param, initializing log4j
with BasicConfigurator");
    }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);
        } else {
            System.err.println(log4jProp + " file not found, initializing
log4j with BasicConfigurator");
    System.out.println("log4j configured properly");
    logger = Logger.getLogger(ServletInit.class.getName());

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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message