just do it
2007-04-26 07:26:47 UTC
我sourcecode如下
Logger logger;
Properties logp = new Properties();
try {
logp.load(utf16.class.getClassLoader()
.getResourceAsStream( "./Log4j.properties"));
} catch (IOException e) {
e.printStackTrace();
}
PropertyConfigurator.configure(logp);
logger = Logger.getLogger("J2EE");
logger.debug("Hello Log4j");
logger.info("Hi Log4j");
而./Log4j.properties如下
log4j.rootLogger=INFO, A1, A2
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=
[%d{yy/MM/dd HH:mm:ss:SSS}][%C-%M] %m%n
# A2 is set to be a file
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=
[%d{HH:mm:ss:SSS}][%C-%M] %m%n
log4j.appender.A2.File=C:/log4j.log
我程式run起來沒問題
可是在log4j.log下卻沒任何資料output
怎會這樣
乾瞎!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.96.194.99
Logger logger;
Properties logp = new Properties();
try {
logp.load(utf16.class.getClassLoader()
.getResourceAsStream( "./Log4j.properties"));
} catch (IOException e) {
e.printStackTrace();
}
PropertyConfigurator.configure(logp);
logger = Logger.getLogger("J2EE");
logger.debug("Hello Log4j");
logger.info("Hi Log4j");
而./Log4j.properties如下
log4j.rootLogger=INFO, A1, A2
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=
[%d{yy/MM/dd HH:mm:ss:SSS}][%C-%M] %m%n
# A2 is set to be a file
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=
[%d{HH:mm:ss:SSS}][%C-%M] %m%n
log4j.appender.A2.File=C:/log4j.log
我程式run起來沒問題
可是在log4j.log下卻沒任何資料output
怎會這樣
乾瞎!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.96.194.99