You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Miha Vitorovic <mi...@cosylab.com> on 2011/10/19 08:08:28 UTC

Two questions

Hi all,

I would like to ask 2 questions to confirm my understanding of the log4net.

1) Is there a way to make the log4net server receive anything else than 
internally serialized objects , for example, could we send (and receive) 
the log events in the XML - as produced by XmlLayout ? If I understand 
correctly, not out of the box. Yes/No/Maybe?

If I create a slightly modified "server", can XmlLayout or some othere 
class take the XML produced by XmlLayout and turn it back into the log 
event object?

I'll start searching for the answers as well, but if someone with a 
deeper understanding can answer these, I'd really appreciate it.

Thanks and best regards, Miha


Re: Two questions

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-10-21, Miha Vitorovic wrote:

> I was kind of hoping that XmlLayout has some "inverse" functions
> available as well.

Unfortunately it has not.

Note that unless you enable base64 encoding you may be losing some
information by serializing/deserializing stuff via XML as certain
characters that can occur inside your logging message may not be legal
XML characters and get replaced by a "?" (actually, a configurable
character) via XmlLayout.

Those characters are rare (everything outside of
[\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]) but it is something to keep in
mind.

Stefan

Re: Two questions

Posted by Miha Vitorovic <mi...@cosylab.com>.
On 21.10.2011 12:03, Stefan Bodewig wrote:
> On 2011-10-19, Miha Vitorovic wrote:
>
>> 1) Is there a way to make the log4net server receive anything else
>> than internally serialized objects , for example, could we send (and
>> receive) the log events in the XML - as produced by XmlLayout ? If I
>> understand correctly, not out of the box. Yes/No/Maybe?
> By "the log4net server" I assume you mean the RemoteLoggingServer
> plugin.  This one uses .NET remoting and accepts an array of
> LoggingEvent object serialized the way .NET remoting does - i.e. using
> binary serialization.
>
>> If I create a slightly modified "server", can XmlLayout or some othere
>> class take the XML produced by XmlLayout and turn it back into the log
>> event object?
> The "turn it back" will be tricky, there is no built-in support for this
> and you'd have to code it yourself.  This is in addition to writing the
> "slightly modified" plugin and a new appender that looked similar to the
> RemotingAppender.

Thank you for answer Stefan. Exactly as I suspected. I just needed to 
understand the scope of work required.
I was kind of hoping that XmlLayout has some "inverse" functions 
available as well.

Thanks and br, Miha


Re: Two questions

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-10-19, Miha Vitorovic wrote:

> 1) Is there a way to make the log4net server receive anything else
> than internally serialized objects , for example, could we send (and
> receive) the log events in the XML - as produced by XmlLayout ? If I
> understand correctly, not out of the box. Yes/No/Maybe?

By "the log4net server" I assume you mean the RemoteLoggingServer
plugin.  This one uses .NET remoting and accepts an array of
LoggingEvent object serialized the way .NET remoting does - i.e. using
binary serialization.

> If I create a slightly modified "server", can XmlLayout or some othere
> class take the XML produced by XmlLayout and turn it back into the log
> event object?

The "turn it back" will be tricky, there is no built-in support for this
and you'd have to code it yourself.  This is in addition to writing the
"slightly modified" plugin and a new appender that looked similar to the
RemotingAppender.

Stefan