How to track log messages by thread
From Resin 3.0
- Main article: log
Since Resin is a multithreaded program, logging messages from many requests and threads are serialized in the log files. In some cases, it it useful to keep track of the log messages for a single thread.
The format attribute in the <log> tag lets you customize the log message to include the thread id The format is a string with interpolated EL expressions specifying the format. The value ${log.threadId} adds a thread identifier to the message, while ${log.message} returns the log message.
So an example format might be
<log name="" level="finer" path="log/debug.log" format="<${log.threadId}> ${log.message}"/>
The output might look like:
[14:54:00.526] <11> [1] GET /test/hello_java.jsp HTTP/1.1 [14:54:00.528] <11> [1] Remote-IP: 127.0.0.1:64395 [14:54:00.528] <11> [1] Accept: */* [14:54:00.529] <11> [1] Accept-Language: en [14:54:00.529] <11> [1] Accept-Encoding: gzip, deflate [14:54:00.532] <11> [1] User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko) Safari/417.8 [14:54:00.533] <11> [1] Connection: keep-alive [14:54:00.534] <11> [1] Host: localhost:8080 [14:54:00.557] <11> invoke (uri:/hello_java.jsp -> resin-jsp) [14:54:00.576] <11> uri:/hello_java.jsp(cp:/test,app:/Users/ferg/ws/test-resin/webapps/test) -> /Users/ferg/ws/test-resin/webapps/test/hello_java.jsp [14:54:00.723] <11> loading pre-compiled page for /hello_java.jsp [14:54:00.767] <11> [1] HTTP/1.1 200 OK [14:54:00.767] <11> [1] Content-Type: text/html [14:54:00.767] <11> [1] Transfer-Encoding: chunked [14:54:00.768] <11> [1] write-chunk(7) [14:54:00.769] <11> [1] keepalive