Re: Concurrent Logging: How?
From: Raymond DeCampo (rdecampo_at_spam.twcny.spam.rr.spam.com.spam)
Date: 10/10/04
- Previous message: Daniel Parker: "Re: Concurrent Logging: How?"
- In reply to: Daniel Parker: "Re: Concurrent Logging: How?"
- Next in thread: Calum Grant: "Re: Concurrent Logging: How?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 10 Oct 2004 13:27:16 GMT
Daniel Parker wrote:
> "Ravi Shankar" <sujashankar@pacific.net.sg> wrote in message
> news:cka0m0$epc$1@nobel.pacific.net.sg...
>
>>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
>>
>
> Isn't this more an issue of having an appropriate viewer for the log?
> Assuming you create log entries that identify the user, by session id or
> whatever, you just need a viewer that will group them appropriately. If you
> take this strategy, you will of course need to format the log entries
> consistently. The alternative strategy, of grouping the messages before
> they are written to the log, would be bad because generally you want to
> write the messages to a physical medium as soon as possible, for obvious
> reasons. You could write the messages to a database, in which case queries
> on user would be easier, but there's an obvious downside to that as well.
> So my advice: format your messages consistently, include a user field, and
> implement an appropriate viewer.
>
log4j has a few tools to help you to this end. You can use NDC or MDC
to associate the user to the thread; that way you do not need to change
all of your existing log statements. Also, if you write the log in XML
format (there is a formatter in log4j for this) it can be parsed by
Chainsaw (a GUI tool from log4j) giving you a powerful viewer. You can
also configure log4j to send messages directly to Chainsaw via a socket.
For more details and assistance I suggest you refer to the log4j-users
mailing list from apache.org.
HTH,
Ray
-- XML is the programmer's duct tape.
- Previous message: Daniel Parker: "Re: Concurrent Logging: How?"
- In reply to: Daniel Parker: "Re: Concurrent Logging: How?"
- Next in thread: Calum Grant: "Re: Concurrent Logging: How?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|