logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Cheshire" <cheshira...@gmail.com>
Subject dynamically adding to a log file name?
Date Thu, 09 Nov 2006 02:40:57 GMT

I have a process that sends an xml request to an external server and
receives an xml response back. For purposes of debugging, I need to
capture the request and response in separate files but with similar
names so that I can pair them up easily.

Currently I am using James Stauffer's DateFormatFileAppender (very
useful James!!) with the filename set to
'${log4j.log.dir}/'yyyy/MM/dd/'qresponse.'yyyyMMdd-HHmmss-S'.xml' (and
similar for the request) to log each request and response to a
separate file each time. (I do understand that there is potential for
2 requests at the same millisecond, but this is really for debugging
only and not production, so I can pretty much guarantee that won't

By using the milliseconds in the filename I can get unique requests or
responses, but each request and subsequent response will have slightly
different timestamps. I might get two requests processed before I get
the response back for the first, which makes it slightly difficult to
match them up.

I don't want to log the request and response to the same file, because
then it is no longer a well formed XML document that I can look at in
an XML browser.

Is there some way I can dynamically add something (like my internal
requestid) to the file names at log time such that I can pair the log
files up, without forcefully finding the appender and reconfiguring it
each time (which would be rather slow)?

If all else fails I can add an XML comment to the end of the file via
the pattern layout, but I am looking for something that will help for
scan value in matching the files up.



To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message