自定义log4j类不打印类名称从中写入日志

时间:2013-10-30 13:27:04

标签: java logging log4j

我有自定义记录器类 mycust.log.LoggerLog4j.java,每当我想记录我将使用的任何消息时,如Log.info("Some Message")。假设我在方法com/TestLog.java10行的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`

LoggerLog4j.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();
        }
    }

0 个答案:

没有答案