The latest version of Chainsaw V2 can help you once you've added
unique identifiers to each event (via MDC) to slice & dice logs - you
can even combine client and server logs together.
Chainsaw V2 is available via WebStart here:
http://logging.apache.org/log4j/docs/chainsaw.html
Chainsaw can display and tail a log file generated by any logging
framework using LogFilePatternReceiver.
Here's a link to the LogFilePatternReceiver javadoc, describing the
'logFormat' keywords:
http://cvs.apache.org/viewcvs.cgi/lo...1.19&view=auto
If you want to tail your log file, modify the below-provided xml as
needed and save as chainsaw.xml.
Inside Chainsaw, select:
view-show application wide preferences
- enter the URL of this chainsaw.xml in the 'automatic configuration
URL' field
- restart chainsaw
chainsaw.xml:
------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
<plugin name="logFileReceiver"
class="org.apache.log4j.varia.LogFilePatternReceiv er">
<param name="fileURL" value="file:///c:/downloads/log4j/sample.log" />
<param name="timestampFormat" value="yyyyMMddHHmmssSSS"/>
<param name="logFormat" value="TIMESTAMP LEVEL(FILE:LINE)#CLASS,LOGGER
THREAD!MESSAGE"/>
<param name="name" value="logfileReceiver" />
<param name="tailing" value="true" />
</plugin>
<root>
<level value="debug"/>
</root>
</log4j:configuration>
------------------------------
Hope this helps - there is a tutorial available from the 'Welcome' tab
that explains how to use it.
Feel free to send an email to the log4j user mailing list with
questions:
http://logging.apache.org/site/mailing-lists.html
Scott
Calum Grant <ca****@no.onetel.spam.com> wrote in message news:<_P**************@newsfe6-gui.ntli.net>...
Ravi Shankar wrote: Hi all,
I have an enterprise application. I am using Apache Log4J for the logging
purposes. WHen a request is received by the application, it goes throug
servlets and many classes, and the necessary details are logged to files,
which has autorate option. I mean when certain file exceeds the size,
automatically another file is generated for a maximum of 10 files and then
again starts from the first.
So far is so good. Now assume that say 100 users are concurrently making a
request. Since servlets are mutithreaded, the logs generated does not show
each request sequentially. All the logs of all the requests are mixed
together making it difficult and highly spagettic to read and understand.
How can I make the logging strategy such that each user request is written
in a sequential manner so that there are no overlaps of the logs? Please
advise, thanks
You'd need to write a unique request-id in each line of the log. Then
you can apply filters (e.g. grep, perl) to extract useful information
from the log. You could write (or get someone else to write) a script
to process these log-files and collate requests.
You can also use SQL for logging, so then it's slightly easier to apply
queries and filters, for example to order by (request-id, time) instead
of just time.
Calum