[Mono-list] Nothing happens with mono-service and EventLog.WriteEntry
Will Murnane
will.murnane at gmail.com
Thu Feb 15 10:52:47 EST 2007
On 2/15/07, Michael Schurter <michael at susens-schurter.com> wrote:
> 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);
> }
> }
> }
A 2005 posting on this list suggested inverting the test, which makes
the Magic Numbers go away:
using System;
PlatformID id = Environment.OSVersion.Platform;
if( id == PlatformID.Win32NT
|| id == PlatformID.Win32S
|| id == PlatformID.Win32Windows
|| id == PlatformID.WinCE)
{
Console.WriteLine ("NOT running on Unix");
}
else
{
Console.WriteLine ("Running on Unix");
}
This is probably still working, but I haven't tried it. Your mileage may vary.
Will
More information about the Mono-list
mailing list