开发者

Log 4j configuration for adding file name and line number

I am using 开发者_JAVA技巧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


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."


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜