我有自定义记录器类 mycust.log.LoggerLog4j.java
,每当我想记录任何我会使用的消息时Log.info("Some Message")
。假设我正在方法中com/TestLog.java
的行中写下这一行。10
printLogTest()
当前日志:
2013-10-30 16:32:50,528 INFO [main] [45:mycust.log.LoggerLog4j.java][log] - Some Message
预期日志:
2013-10-30 16:32:50,528 INFO [main] [10:com.TestLog.java][printLogTest] - Some Message
Log4j.properties 条目:
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%t] [%L:%C.%F][%M] - %m%n
Log4j 版本:
`log4j-1.2.14.jar`
记录器Log4j.java:
private static void log(Priority p, Object o, Throwable t) {
try {
Logger logger = org.apache.log4j.Logger.getLogger(this.className);
logger.log(p, o, t);
} catch (Exception e) {
// Logged to sys to avoid infinite cycle
e.printStackTrace();
}
}