[Mono-dev] Event logging under Mono

Alexander Köplinger alex.koeplinger at outlook.com
Mon Dec 8 23:03:22 UTC 2014


I'd just use a proper logging framework like NLog (http://nlog-project.org/) instead of using the rather Windows-specific event log implementation.
 
-- Alex
 
From: spyros at microsoft.com
To: mono-devel-list at lists.ximian.com
Date: Mon, 8 Dec 2014 22:38:26 +0000
Subject: [Mono-dev] Event logging under Mono









[Sorry if duplicate. I think I originally sent to wrong alias]
 
Hi –
 
I am trying to implement logging for a small application running under Mono on a Raspberry Pi. Unfortunately I have been unable to create an event log despite following guidance that I have found on the Net,
 and am wondering if there is best practice on how to do this. FWIW, the steps I have taken are as follows:
 
1.      
On the Raspberry Pi, I created /var/lib/mono and /var/lib/mono/eventlog directories, set directory permission on each to 777 per
http://lists.ximian.com/pipermail/mono-devel-list/2006-August/019853.html.

2.      
Ran the following .NET code, based loosely on
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog(v=vs.110).aspx:

 
using System;
using System.Text;
using System.Diagnostics;

namespace Logging
{
    class Program
    {
        static void Main(string[] args)
        {
            if (!EventLog.SourceExists("MySource"))
            {
                EventLog.CreateEventSource("MySource", "MyNewLog");
                Console.WriteLine("CreatedEventSource");
                Console.WriteLine("Exiting, execute the application a second time to use the source.");
                return;
            }
            else
                Console.WriteLine("Found the EventLog Source.");
            return;
        }
    }
}
 
If I run this twice on a Windows 8 machine, the first time it comes back with “CreatedEventSource”, the second time it comes back with “Found the EventLog Source”, and the Windows Event Log has a new log entitled
 MyNewLog. However, if I run it on the Raspberry Pi under mono, I get the message “CreatedEventSource” no matter how many times I run it, and no files are created in /var/lib/mono/eventlog.
 
What am I missing, or what should I try instead?
 
Spyros Sakellariadis
Microsoft Open Technologies, Inc.
spyros at microsoft.com
 
 




_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20141209/f4e0f03d/attachment-0001.html>


More information about the Mono-devel-list mailing list