In normal usage of Log4J, this is a standard practice
Logger logger = Logger.getLogger("com.acme.someclass");
if (logger.isDebugEnabled())
{
logger.debug("This is my debug message" );
}
What if the Category (ie 'com.acme.someclass') isn't a static value but some
dynamic value ? One typical example would be an application that needs to parse some
request and
within the request, there are some contextual information that defines the Category
name ?
So prior to knowing whether the Category of a logger is debug or infor etc.., we still
like to
buffer some messages and then once the Category can be defined, the debug messages can
be flushed out
or throw away.
eg.
Get a 'Buffer' Logger instance
Get Request from Client
logDebug("Got request from Client. about to parse")
parsedRequest = ParseRequest()
logDebug("Request Parsed")
String contextInfo = Get from parsedRequest
Re-get the Log4j logger using contextInfo as category (ie newLogger=
Logger.getLogger( contextInfo ) )
if ( newLogger is debug enabled)
flush all the previous messages to the appender
I am curious if anyone has similar requirements or have implememented something
similar. I've thought
about writing a custom BufferLogger but would rather see what else is out there.
Thanks in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]