Ralph,
My intention is basically to replace all "\n" in the message with the
ThreadContext for our application.
I think RegexReplacement is not taking variables for pattern and
substitution.
I am using the following in pattern-layout, but the substitution is not
happening correctly, and also by looking at the code, it looks like code do
not support.
<PatternLayout>
<pattern>%-5p | %X | %d{MM-dd-yyyy HH:mm} |%10sn |
%replace{%msg}{\n}{%%X{host}}%n</pattern>
RegexReplacement class do not have any information about the context, so
it cannot resolve %X{host} for substitution string.
public String format(final String msg) {
return pattern.matcher(msg).replaceAll(substitution);
}
this could be as follows
public String format(final String msg, String paramSubstitution)
{
// substitution should be formatted with the formatter, and then
passed to this method.
return pattern.matcher(msg).replaceAll(paramSubstitution);
}
Yogi
On Fri, Feb 15, 2013 at 4:04 PM, Ralph Goers <[email protected]>wrote:
> Where are you wanting to do this? In a pattern in the pattern layout you
> just use %X{app name} as you show below. In many places you can use
> ${mdc:name}.
>
> Ralph
>
>
> On Feb 15, 2013, at 12:02 PM, Yogi Nerella wrote:
>
> > Hi,
> >
> > I want to replace some constant strings with the MDC.context() values?
> >
> > Does regularexpress replace support this?
> >
> > Ex:
> > %replace{%msg}{myappname}{%X{appname}}
> >
> > Thanks
> > Yogi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>