[Mono-dev] Event logging under Mono

Spyros Sakellariadis (MS OPEN TECH) spyros at microsoft.com
Tue Dec 9 18:25:33 UTC 2014


Adding the SetEnvironmenVariable in Main worked – thanks!

FYI – another suggestion on the mailing list was to use NLog. Implemented that as well, and that worked like a charm too.

Spyros Sakellariadis
MS Open Technologies, Inc.
Office +1(425) 707-7623<callto:+14257077623>   -  Mobile +1(425) 444-1884<callto:+14254441884>

From: Miljenko Cvjetko [mailto:mcvjetko at holisticware.net]
Sent: Tuesday, December 9, 2014 8:21 AM
To: Spyros Sakellariadis (MS OPEN TECH); mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] Event logging under Mono

Hey

this is probably shell variable problem. Did you export it?

I had the same behavior (testing on my Mac). I did not create /var/lib/mono, so I would get exception.
Added following line at the begining of the Main

            Environment.SetEnvironmentVariable( "MONO_EVENTLOG_TYPE", "local");
This way I'm sure variable is in the same shell instance.

after that I got:

    Access to the path "/var/lib/mono" is denied.

So I assume right now it is trying to write to /var/lib/mono/SOMETING.
Stopping here....

So your app did not "pick up" envirnonment variable.

hope this helps

Mel
On 20141209 17:01 , Spyros Sakellariadis (MS OPEN TECH) wrote:
Yes, to local

Sent from my Windows Phone
________________________________
From: Miljenko Cvjetko<mailto:mcvjetko at holisticware.net>
Sent: ‎12/‎9/‎2014 7:56 AM
To: mono-devel-list at lists.ximian.com<mailto:mono-devel-list at lists.ximian.com>
Subject: Re: [Mono-dev] Event logging under Mono
Hi

Did You set MONO_EVENTLOG_TYPE?   win32|local|null;

cheers

mel
On 20141208 23:38 , Spyros Sakellariadis (MS OPEN TECH) wrote:
[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<http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog%28v=vs.110%29.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<mailto:spyros at microsoft.com>





_______________________________________________

Mono-devel-list mailing list

Mono-devel-list at lists.ximian.com<mailto: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/a5555132/attachment-0001.html>


More information about the Mono-devel-list mailing list