title: How to collect logs in jboss related to a single request?
body: <p>I am developing a Java EE web application that is run under JBoss.</p>
  
  <p>I want to do the following:
  When a user sends an http request (by opening a page or through AJAX) all the logs that are related to this request are collected and then saved into the database. By related I mean that they are being logged during the process of handling the current request. Tha hardest part is collecting the logs related to a single request.</p>
  
  <p>I was looking into this solution:</p>
  
  <p>JBoss uses log4j for logging. When the app starts, a start listener registers a log4j appender that collects all the logs into a ThreadLocal field. In the end of the request handling the logs are taken from the field and saved into the DB.</p>
  
  <p>But, it seems now, that log4j appenders work in other threads. This makes this solution imposible.</p>
  
  <p>Do you have any idea, how this could be made?</p>
  
  <p>Thanks,
  Artem B.</p>