logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: Format log message based on thread?
Date Thu, 15 Jan 2009 23:05:31 GMT
One other point I want to mention:

This technique allows you to create separate log files based on thread name,
for which you could specify different layouts.

If what you're trying to do is get a single log file to contain all events
with some events formatted differently, I wouldn't use this technique.
Defining two appenders to write to the same log file can cause unexpected
behavior.

Scott

On Thu, Jan 15, 2009 at 2:49 PM, Scott Deboy <scott.deboy@gmail.com> wrote:

> Add an ExpressionFilter to an Appender which specifies the layout you want
> for that specific thread (expressionfilter is in the extras companion, and
> will work with log4j 1.2.15):
> http://logging.apache.org/log4j/companions/extras/index.html
>
> You'll need to use two  may wa'll probably want two appenders
> An example expression for only processing events from a specific thread
> would be:
>
> THREAD == 'My thread name'
>
> You can also use the case-insensitive partial-text match operator ~= to
> match a part of the thread name, or the LIKE operator to perform regular
> expression matching.
>
> This is the same expression syntax you use in Chainsaw V2 to filter,
> colorize and search for events.  The best description of the expression
> syntax is in the Chainsaw tutorial (available from the help menu).
>
>
> On Thu, Jan 15, 2009 at 2:34 PM, yesnid <nsimi@pelco.com> wrote:
>
>>
>> Hello All,
>>
>> Does anyone know if there is a way to alter the formatting of log messages
>> from a logger based on which thread the message it is coming from?
>>
>> Thank you.
>> --
>> View this message in context:
>> http://www.nabble.com/Format-log-message-based-on-thread--tp21488373p21488373.html
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message