0

I have Custom logger Class mycust.log.LoggerLog4j.java, whenever I want to log any message I will use like Log.info("Some Message"). Say I am writing this line in com/TestLog.java at line 10 in method printLogTest().

Current Log:

2013-10-30 16:32:50,528 INFO  [main] [45:mycust.log.LoggerLog4j.java][log] - Some Message

Expected Log:

2013-10-30 16:32:50,528 INFO  [main] [10:com.TestLog.java][printLogTest] - Some Message

Log4j.properties entry:

log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%t] [%L:%C.%F][%M] - %m%n

Log4j version :

`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();
        }
    }
Nikos Paraskevopoulos
  • 39,514
  • 12
  • 85
  • 90
Azhar
  • 933
  • 1
  • 12
  • 28
  • This seems to be a duplicate of http://stackoverflow.com/questions/2905611/printing-the-source-class-in-a-log-statement-with-a-log4j-wrapper – Sietse van der Molen Oct 30 '13 at 13:35
  • 1
    a static void log calling "this.className" ? "this" is not supposed to be visible in a static method, is it ? – Julien Oct 30 '13 at 13:35

0 Answers0