Thanks Nicko,
I can understand where you are coming from with keeping the XMLLayout
generating only the fragments. However, imagine the following:
<appender name="RollingFile"
type="log4net.Appender.RollingFileAppender">
<file value="c:\\example.xml"/>
<appendToFile value="true"/>
<preMessage value="<?xml version="1.0" ?>
<!DOCTYPE log4net:events SYSTEM "log4net-events.dtd"
[<!ENTITY data SYSTEM
"abc">]>
<log4net:events version="1.2"
xmlns:log4net="http://log4net.sourceforge.net/">
"/>
<postMessage value="</log4net:events>"/>
<maximumFileSize value="50KB"/>
<maxSizeRollBackups value="2"/>
<layout type="log4net.Layout.XMLLayout">
<conversionPattern value="%p %d [%t] - %m%n"/>
</layout>
</appender>
As you can see I've added 2 appender parameters called preMessage and
PostMessage. Each time the rolling file appender creates a new file it would
put the preMessage at the top and when it closes a file and moves onto the
next one it would put a postMessage at the end of the file. The preMessage
could be used for other things such as help messages or copyright messages
as well. It is thus independent of the layout used.
Does this sound like a reasonable solution? Do you think it could be
implemented and if I were to implement it would the log4net community be
interested in such an enhancement?
Matthew James Easlea
-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED]
Sent: Monday, 7 June 2004 10:17 AM
To: 'Log4NET User'
Subject: RE: XML Layout
The XmlLayout generates XML Fragments for each message. XML does not lend
itself too well to a streaming format.
When using the XmlLayout with the FileAppender or RollingFileAppender the
file written will not be a valid XML document. It is a valid XML fragment.
However it can be included in a document.
The output of the XmlLayout consists of a series of log4net:event elements.
It does not output a complete well-formed XML file. The output is designed
to be included as an external entity in a separate file to form a correct
XML file.
For example, if 'abc' is the name of the file where the XmlLayout output
goes, then a well-formed XML file would be:
<?xml version="1.0" ?>
<!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM
"abc">]>
<log4net:events version="1.2"
xmlns:log4net="http://log4net.sourceforge.net/">
&data;
</log4net:events>
This approach enforces the independence of the XmlLayout and the appender
where it is embedded.
Nicko
> -----Original Message-----
> From: Matthew Easlea [mailto:[EMAIL PROTECTED]
> Sent: 06 June 2004 23:46
> To: 'Log4NET User'
> Subject: XML Layout
>
> Hi,
>
> When I use XMLLayout using the rolling file appender is there
> anyway for it to create valid XML files. By this I mean with
> opening and closing <?XML> tag etc?
>
> Cheers
>
> Matthew James Easlea
>
>
>