You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by James Green <Ja...@occam-dm.com> on 2009/06/19 11:50:44 UTC

Event Log Weirdness.

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


RE: Event Log Weirdness.

Posted by James Green <Ja...@occam-dm.com>.
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.

RE: Event Log Weirdness.

Posted by James Green <Ja...@occam-dm.com>.
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]





RE: Event Log Weirdness.

Posted by Radovan Raszka <ra...@hasam.cz>.
Do you call ActivateOptions() when Threshold property is changed?
Radovan

-----Původní zpráva-----
Od: James Green [mailto:James.Green@occam-dm.com] 
Odesláno: 19. června 2009 12:00
Komu: Log4NET User
Předmět: RE: Event Log Weirdness.

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. 

-----Original Message-----
From: James Green
Sent: 19 June 2009 10:51
To: Log4NET User
Subject: Event Log Weirdness.

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


scanned by MessageLabs [www.messagelabs.com]

scanned by MessageLabs [www.messagelabs.com]



RE: Event Log Weirdness.

Posted by James Green <Ja...@occam-dm.com>.
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. 

-----Original Message-----
From: James Green 
Sent: 19 June 2009 10:51
To: Log4NET User
Subject: Event Log Weirdness.

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


scanned by MessageLabs [www.messagelabs.com]

scanned by MessageLabs [www.messagelabs.com]