[Mono-list] Nothing happens with mono-service and EventLog.WriteEntry
Michael Schurter
michael at susens-schurter.com
Thu Feb 15 10:35:10 EST 2007
On Mon, 2007-02-12 at 22:06 +0100, Gert Driesen wrote:
...snip...
> What part is clumsy about it ? I started working on an MWF gui for the
> eventlog which basically is a light-weight version of the windows
> EventViewer.
I guess I expected a syslog-like backend. I find the EventLog in
Windows a lot less useful and harder to read than syslog in general, so
for me have a 100% accurate implementation is a bad thing.
However, I discovered this little snippet of code should keep Windows
happy as well as give me the syslog support I love:
private void SmartLog (string message)
{
int p = (int) Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) {
// UNIX - Use Syslog
Mono.Unix.Native.Syscall.syslog (
Mono.Unix.Native.SyslogLevel.LOG_INFO,
message);
} else {
// Windows - Use EventLog
EventLog.WriteEntry (message);
}
}
}
Obviously not the most "robust" solution, but its a quick and easy hack
to make everyone happy! ;)
> You can find this in the winforms-tools svn module.
I'll have to check that out! While I've already professed my love of
syslog, there's definitely a lot of room for improvement in the logging
world. Thanks for all of your hard work and help!
> Gert
More information about the Mono-list
mailing list