DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43403>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43403

           Summary: PatternLayout: new format modifer: prefix if non-empty
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Layout
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


PatternLayout needs new format modifier: prefix to be used when parameters 
evaluates to the non-
empty string.

So pattern could be written as:

[%c%{x;prefix="-"}] %m

that outputs

[app.Something-7777] message

if NDC is 7777, and

[app.Something] message

if NDC is empty (no chars before square bracket).

This is must have thing for MDC: when several should be printed, and some of 
them could be unset:

[%c${X;key=clientId;prefix=" clientId="}%{X;key=city;prefix=" city="}] %m

should be evaluated to

[app.something clientId=777 city=Moscow] message
[app.something clientId=888] message
[app.something city=Moscow] message
[app.something] message

depending on what values are set in MDC.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to