4

I am using Log4j for logging my application activity. In my local environment it was logging like

Fiilename:linenumber: your logging message

then I created archive and deploy in another environment then its logging without file name, can any one clear me which property if logger do this. thanks

1
  • Only without filename, but still with line number? Code that is release built don't contain line number information. Commented Jun 7, 2011 at 6:52

2 Answers 2

5

In log4j.properties file set

log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p %l - %m%n

Here %l specifies to generate the location information. According to the spec for PatternLayout : "The location information depends on the JVM implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses."

Sign up to request clarification or add additional context in comments.

Comments

3

Look at the documentation for PatternLayout. Note that figuring out file name and file number is slow (I guess it involves getting a stack trace and analyzing it).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.