Display thread id instead thread name in log

后端 未结 10 769
南笙
南笙 2020-12-31 00:34

I have a Struts application with log4j to display information about application.

The pattern to format log\'s output is as follows:

log4j.appender.RA         


        
10条回答
  •  感情败类
    2020-12-31 01:11

    I think it is not possible to show thread id with standard log4j formatting. I also investigated through code of PatterParser class an found nothing which can be useful. I found some custom solutions, but only for IBM server which has %i option:

    %i: Inserts the thread ID. Unlike the thread name (indicated by %t), this is thread's numeric ID. Note that this parameter is particular to Initiate, while the other parameters listed here are standard with log4j.

    See this link

提交回复
热议问题