logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jm <jmugur...@gmail.com>
Subject Re: how to change the %m in PatternLayout
Date Wed, 09 Apr 2008 11:16:37 GMT
Thanks for the replies.

I achieved it by a Filter that puts the modified value in MDC

thanks all

On Tue, Apr 8, 2008 at 8:15 PM, Matthew Kemp <mattkemp@gmail.com> wrote:
> You could create your own Layout class. While you loose some of the
>  flexibility of the PatternLayout class you can perform any message
>  formatting/encoding. The Layout class takes a LogEvent and returns the
>  formatted string. It might also be possible to extend the PatternLayout.
>
>  Matt
>
>
>
>
>
>  On Tue, Apr 8, 2008 at 12:57 PM, jm <jmuguruza@gmail.com> wrote:
>
>  > Hi,
>  >
>  > I need some functionality I don't know how to implement:
>  > Right now my big codebase is full of logger.info("a message"); stuff.
>  > I have a new requirement to format log files in a specific way, for
>  > instance:
>  > 20080408-18:57:24|ProcessA.java|23|hostname|this is where the message goes
>  > As you can see, fields are separated by |, and I have been able to do
>  > all required by setting some stuff as MDC and by using existing values
>  > from PatternLayout. The only remaining thing is that in case the %m
>  > contains a pipe, it must be escaped to \|.
>  >
>  > I wish I could do that in a centralized way (maybe even subclassing
>  > some log4j class) instead of changing all the calls to logger.info()
>  > to LogUtil.log() and escaping the pipe in the new static method.
>  >
>  > is that feasible?
>  >
>  > many thanks
>  > javi
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>  > For additional commands, e-mail: log4j-user-help@logging.apache.org
>  >
>  >
>

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


Mime
View raw message