开发者

Customizing Log4j to filter PatternLayout

I have just starting migrating to WLS 10.x and have noticed that the thread name [%t] for WL is quite verbose and more informative than I need for my deployment needs.

Ultimately, I only care about the thread ID but WL gives me this:<

[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'
~

Does anybody 开发者_JAVA百科know if there is a way in log4j to write a custom filter that will allow me to override PatternLayout so I can parse the WLS Thread Name to just output the thread ID which in this case above is 0 ? I'd rather extend then customize as it makes upgrading libraries so much easier.


You want to write your own conversion word. In logback you can do so within minutes. See the section on custom conversion specifiers.

If you are really lazy and could not be bothered with writing a custom conversion word, just tell the the existing throwable to trim the thread name to 26 characters. The pattern would be "%.-26thread". I chose 26 because that is the length of "[ACTIVE] ExecuteThread: '0'".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜