1

除了Standard outputand之外standard error,Java 中还有其他类型的控制台输出流吗?我正在使用 Jenkins(可能不相关)并且我想在我的控制台中添加一个新的输出部分,除了Standard outputand standard error; 类似的东西Special Values。我正在使用log4j,但我也可以使用System.out等。

4

1 回答 1

0

You could do it using your logger.

For instance:

import org.apache.log4j.Logger;

public class MyClass {
    private static Logger logger = Logger.getLogger("name"); // declare this as field
    ...
    public void someMethod() {
        logger.info("someMethod was invoked");
    }
}

additionally your log4j.properties file will look like:

log4j.rootLogger=debug, file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=/path/to/logs/application.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%t %-5p %c{2} - %m%n
于 2012-07-12T04:57:02.760 回答