The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.
| Author |
Messages |
|
James Green
 |
| 06/19/2009 11:50 AM |
|
Hi All,
I'm just looking into an odd issue. I have an EventLogAppender being configured in C#. If I set this up to append to the "Application" log all is fine.
However, when I ask it to create a custom event log called LogTest its not working as expected.
Now the obvious thing is that the process doesn't have permissions ... it does. It created the new LogTest event log without problems but never writes to it ...
From reading the log4net docs it would seem that if I can create the log (which I can) it stands to reason that it should also be able to write to it.
This isn't an ASPNET process either, its a desktop windows application ... the C# that configures the LogAppender 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.Off; _eventLogAppender.ActivateOptions(); BasicConfigurator.Configure(_eventLogAppender); }
I can only assume that I'm missing something in this setup process but I can't see anything in the Xml versions of configuration that suggest what to do ...
Cheers,
James Green Technical Lead - Core Systems Occam DM Ltd Tel: +44(0)1761234716
|
|
|
|
|
James Green
 |
| 06/19/2009 11:59 AM |
|
I should also point out that I know the Threshold is Off ...
I have explicit methods that switch this on in order to prevent the event log from being swamped with log entries as the processes we run here could produce millions of logs a day ...
Our default log destination is a SQL Database ...
James.
|
|
|
|
|
Radovan Raszka
 |
| 06/19/2009 12:22 PM |
|
Do you call ActivateOptions() when Threshold property is changed? Radovan
|
|
|
|
|
James Green
 |
| 06/19/2009 12:24 PM |
|
Do you call ActivateOptions() when Threshold property is changed? Radovan
Indeed I do ...
public static void LogToEventLog(bool logToEventLog) { if (_eventLogAppender == null) return;
if (logToEventLog) { _eventLogAppender.Threshold = Level.All; } else { _eventLogAppender.Threshold = Level.Off; } _eventLogAppender.ActivateOptions(); }
This is being shown in my console window:
log4net: EventLogAppender: Changing event source [MyFirstApp] from log [Applicat ion] to log [log4net] log4net: EventLogAppender: Source [MyFirstApp] is registered to log [log4net]
|
|
|
|
|
James Green
 |
| 06/19/2009 1:22 PM |
|
Hi Again,
I seem to have some info to work on. Trying to log into my custom event log has generated this in the Application event log:
The description for Event ID ( 0 ) in Source ( MyFirstApp ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: 2009-06-19 12:11:27,234 14 INFO <MachineName> <username> Logging.TestHarness.vshost.exe (line: 220) Logging.TestHarness.LogEntryCreator - Message number 71 System.Exception: Arses!
Hmm ... Any ideas would be great.
Cheers,
James. |
|
|
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.7
|