[Mono-list] [solved] Re: Logger viewer]

Adrien Dessemond adrien.dessemond at softhome.net
Sat Nov 24 21:41:14 EST 2007


Sorry forgot to include the list in my answers. So here is the last 
anwser made. Please, free feel to comment/correct/add any opinions

Regards,

Adrien


--
There's nothing to understand : Mono logs are in different format as the
traditional syslog. Under Mono, System.Diagnostics.EventLog behaviour
varies according how MONO_EVENTLOG_TYPE is set :

* 'local[/path]' : a standalone text file, put under /path (if 'local' is
given without a path everything goes in /var/lib/mono/eventlog
(Linux/Unix) or %APPDATA%\mono\eventlog under Windows by default)

* 'win32' : Windows event log (of course if your application runs under
Windows)

* unset : drop everything (logs nothing).

So, in no way EvenLog is able to use the SysLog daemon (under
Linux/Unices) and this is a design choice that have been made and you have
to live with that. The log format used by Mono is one of the reasons I
think, but they could had choosen this way to go for portability issue.

If you want to go with the syslog daemon, your only choice is to handle
the functionality by wrapping around Mono.Unix.Native.Syscall.syslog. The
Facade pattern is somewhat wonderful because, from your application point
of view, it totally hides the complexity of having to manage 2 different
logging possibilities. It just trow what it has to to the facade, and the
facade will redirect the job to the right logg backend.

More info on the facade pattern is here :

http://en.wikipedia.org/wiki/Facade_pattern

For my suggestion (and it is only a suggestion, you are not required to
use a design pattern altough it is highly recommended to use them) :

Generic Logger <---+--- Windows Event Log (EventLog wrapper)
                   |
                   +--- Linux/Unix Syslog (Mono.Unix.Native.Syscall.syslog
wrapper)


Generic Logger checks whether the current operating system is Windows or
Linux/Unix and provide a public manner to open/close/write to/read from
event log. It also worries about managing the backend to use.

E.g. of pseudo code :

interface ILoggingFacilityPluggable  :

    public bool OpenLog();
    public void CloseLog();
    ....


class GenericLogger

Attributes:
    ILoggingFacilityPluggable  _internalLoggingFacility;

Methods :

    constructor {
      if( running on Windows )
          internalLoggingFacility = new WindowsEventLog();
          MONO_EVENTLOG_TYPE = win32;
      else
          internalLoggingFacility = new Syslog();
      }

    }

    // Implement your public methods
    public bool OpenLog()
    {
        internalLoggingFacility.OpenLog();
    }


class WindowsEventLog : ILoggingFacilityPluggable
... ILoggingFacility  implementation around System.Diagnostics.EventLog


class Syslog : ILoggingFacilityPluggable
... ILoggingFacility  interface implementation around
Mono.Unix.Native.Syscall.syslog





More information about the Mono-list mailing list