[logback-user] Can MDC values take a default

Amit Mohan amit.mohan at teamaol.com
Mon Oct 21 21:07:39 CEST 2013


I have this pattern and it's working :

<pattern>%d{HH:mm:ss} %-5p [%t] [%c{1}] [%X{amtrac.serviceName}] 
[%X{amtrac.method}] [%X{amtrac.clientProcessName}] 
[%X{identity_user_context_guid}] [%X{identity_user_context_username}] 
[%X{identity_user_context_partner_id}] [%X{amtrac.tx}] 
MESSAGE=[%m]%n</pattern>

However, I would like to replace a NULL if any of the MDC is null as a 
default value so...

<pattern>%d{HH:mm:ss} %-5p [%t] [%c{1}] [%X{amtrac.serviceName*:-NULL*}] 
[%X{amtrac.method*:-NULL*}] [%X{amtrac.clientProcessName*:-NULL*}] 
[%X{identity_user_context_guid*:-NULL*}] 
[%X{identity_user_context_username}] 
[%X{identity_user_context_partner_id}] [%X{amtrac.tx}] 
MESSAGE=[%m]%n</pattern>

I tried it but it seems like it totally stops logging anything.

Thanks in advance!
-Amit Mohan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20131021/61d6df06/attachment-0001.html>


More information about the Logback-user mailing list