ok, this works for ${...} expressions in the configuration, but I don't see how
it would
apply to pattern evaluation. To simplify and rephrase my original question:
Given a pattern layout with a pattern like: %X{REQUEST_ID}
is it possible to define a default value that will be printed
if the thread never executed ThreadContext.put("REQUEST_ID", "XYZ")?
I tried ${mdc:REQUEST_ID} + a Property REQUEST_ID, but that
will only be evaluated when the configuration is parsed.
Oliver
> Yes, it supports default values. Specify them as properties at the beginning
> of your configuration. Then when you specify something like ${sys:foo} if foo
> is not defined as a system property the default value will be used,
>
> Ralph
>
>> On Sep 30, 2013, at 3:30 AM, Oliver Flege <[email protected]> wrote:
>>
>> Hi,
>>
>> I am considering to switch from slf4j/logback to log4j2;
>>
>> in slf4j/logback, I can specify a default value for a missing mdc entry
>> like this:
>>
>> <pattern>%d{HH:mm:ss} %X{FOO:--} %c{0} - %m%n</pattern>
>>
>> which would print "-" if mdc.get("FOO") is null (the ":-" separates
>> the key and the default value).
>>
>> Having a defined number of tokens/fields at the beginning of the log message
>> makes it easier to process it with awk/cut etc.
>>
>>
>> Does log4j support default values? - I could not find any hint in the
>> documentation
>>
>>
>>
>> Regards,
>> Oliver
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
--
Oliver Flege
Senior Software Engineer | vwd group
vwd Vereinigte Wirtschaftsdienste AG
Stiftsplatz 6/7 | 67655 Kaiserslautern
Telefon: +49 631 3649-0 | Telefax: +49 631 3649-109
[email protected] | www.vwd.com
______________________________________________________________
vwd Vereinigte Wirtschaftsdienste AG
Sitz der Gesellschaft: Tilsiter Straße 1 | 60487 Frankfurt am Main
Handelsregister: AG Frankfurt am Main HRB 81011
Vorstand: Dr. Ralf Kauther
Vorsitzender des Aufsichtsrates: Dr. Thorsten Dippel
____________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]