未创建log4j log.out文件

时间:2016-05-30 10:53:50

标签: java log4j

我想为log4j配置Java Application 我的Java应用程序部署在Tomcat8上安装的Ubuntu 14.04.3 LTS

为此我按照以下网址:

http://www.tutorialspoint.com/log4j/log4j_sample_program.htm

我为此做的配置步骤:

Extract `log4j-1.2.17.tar.gz` file into `/usr/local/`

export CLASSPATH=$CLASSPATH:/usr/local/apache-log4j-1.2.17/log4j-1.2.17.jar

export PATH=$PATH:/usr/local/apache-log4j-1.2.17/

Manually created log4j.properties file into /usr/local/apache-log4j-1.2.17/

Save log4j.properties file with the below content

# Define the root logger with appender file
log = /home/mobile/log
log4j.rootLogger = DEBUG, FILE

# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n

我的Java代码:

import org.apache.log4j.Logger;
public class log4jExample
{
    public getName()
    {
        String xyz = "asdasd as asd";
        Logger log = Logger.getLogger(log4jExample.class.getName());
        System.out.println("INSIDE getName");
        log.debug("DEBUG>>>>>>>>>>>>"+xyz);
        log.info("INFO>>>>>>>>>>>>"+xyz);
    }
}

问题在于,当我在Tomcat8上部署此应用程序并运行时,catalina.out显示INSIDE getName,但对于log4j没有创建文件 { {1}}

0 个答案:

没有答案