2

I have an application where I want to log one thing if a thread has been started, and one thing for the mainthread. Let's say a thread is started, I want the threadname to be in the log. I added %t to the patternlayout, but this also logs the name of the main-thread, which I'm not interested in. Is there any way to log the thread-name only when a thread is started, and not for the main-thread?

user16655
  • 1,901
  • 6
  • 36
  • 60
  • 1
    While there may be other ways to do it, I would look at having separate appenders for the main and sub threads, with the appropriate layout for each. Log4j doesn't really support two appenders writing to the same file, but according to [this answer](http://stackoverflow.com/a/4047350/658663) logback does – beresfordt Mar 17 '16 at 08:21

0 Answers0