logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Cheshire" <cheshira...@gmail.com>
Subject Re: dynamically adding to a log file name?
Date Thu, 09 Nov 2006 18:59:17 GMT
On 11/9/06, James Stauffer <stauffer.james@gmail.com> wrote:
> Search the archives for people who wanted a separate log per MDC value
> (usually login name).
>

OK I found the MDC section in the manual and it looks to be what I
need *except* I cannot create XML style comments in the log file to
contain the MDC value.

If the pattern layout is :
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%m%n\<!-- %X{reqid} --\>%n"/>
    </layout>

(and without the < and >  quoted with the backslash)

I get this exception when the config is parsed :

[#|2006-11-09T10:52:04.051-0800|WARNING|sun-appserver-pe9.0|javax.enterprise.system.stream.err|_ThreadID=44;_ThreadName=Thread-104;_RequestID=47ed9af3-8ced-4d48-894c-180e74673195;|
org.xml.sax.SAXParseException: The value of attribute "value"
associated with an element type "param" must not contain the '<'
character.
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
        at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:598)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:711)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:604)
        at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:733)

Yet the API for PatternLayout specifies "You are free to insert any
literal text within the conversion pattern."

I can't use the XMLLayout because I don't want to create an XML
formatted log file, I just want to dump what I have (which happens to
be XML) to a file and append the XML comment to the end.

Any suggestions?

---------------------------------------------------------------------
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