المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : EventLog logging with log4net



C# Programming
06-19-2009, 03:22 PM
Hi All,

I've been poking around Google / Apache.org trying to get to the bottom of this with no luck. There isn't a lot of info anywhere on configuring log4net using pure C# so I thought I'd try here now.

I can log to the "Application" log with no problems. I can also create "MyLog" event log without problems as well, however, writing to "MyLog" fails to actually write an event log entry. The code I'm using to configure an EventLogAppener is:

public static void ConfigureEventLogAppender(string appName, string logName)
{
PatternLayout layout = GetDefaultLayout();
_eventLogAppender = new EventLogAppender();
_eventLogAppender.ApplicationName = appName;
_eventLogAppender.Layout = layout;
_eventLogAppender.LogName = logName;
_eventLogAppender.Threshold = Level.All;
_eventLogAppender.ActivateOptions();

BasicConfigurator.Configure(_eventLogAppender);
}

Has anyone managed to get this working?

Cheers,

Jammer
My Blog (http://jammer.biz/blog2/) | Article(s) (http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=4664921)