使用带Commons-logging的JDK日志记录不会创建日志文件

时间:2009-08-17 09:13:30

标签: java logging apache-commons-logging

当我运行TestJcLLoggingService类日志消息进入控制台但没有创建日志文件时,如果您知道答案,请帮助我。

下面粘贴了两个源文件。

TestJcLLoggingService.java

package com.amadeus.psp.pasd.logging;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

@Service
public class TestJCLLoggingService {
    private static Log psp_log = LogFactory.getLog(TestJCLLoggingService.class);
    public static String testJCLLoggingServiceMethod(){
        psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService");

        psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService");
        return "This is a test string for JCLLogging";

    }

    public static void main(String[] args){

        testJCLLoggingServiceMethod();

    }

}

logging.properties

handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level = ALL
com.amadeus.psp.pasd.level=ALL
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


java.util.logging.FileHandler.pattern = %h/java%u.log 
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.limit=50000
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append=true

提前致谢。

1 个答案:

答案 0 :(得分:0)

您的问题已在相关主题中得到解答:Java util logging

基本上,您需要在java args或代码本身中设置配置文件(logging.properties)的路径,然后查看右侧文件夹。 (默认为用户主页)