Event Log Weirdness.

2009-06-19 Thread James Green
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.

2009-06-19 Thread James Green
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.

2009-06-19 Thread Radovan Raszka
Do you call ActivateOptions() when Threshold property is changed?
Radovan

-Původní zpráva-
Od: James Green [mailto:james.gr...@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.

2009-06-19 Thread James Green
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.

2009-06-19 Thread James Green
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.


EventLog Fun Continued.

2009-06-19 Thread James Green
Hi All,
 
I'm still at a total loss as to how to get log4net successfully writing
to a custom event log, writing to the Application event log is working
exactly as expected.
 
I have started using the IEventIDLog extension in order to pass over
event IDs to the log messages to see if this makes any difference.
 
I've looked over google a lot over the last couple of days and have
tried everything I have found in terms of suggestions.  The most recent
one being this:
 
http://www.mail-archive.com/log4net-user@logging.apache.org/msg02396.htm
l
 
Which talks of the same error I'm seeing in the application log that I
mentioned before:

I try to write to MyLog and this is entered into the Application 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

I think tried this suggestion:

ILog logger = LogManager.GetLogger(sender);
log4net.ThreadContext.Properties[EventID] = 12;
logger.Info(0,message);

Which didn't make any difference.  I have checked over the Sources key
entries being created in the registery and all seems to be correct in
there as well.  I just never see *anything* making it into the MyLog
event log.

I've probably got another 2 hours left to use on this before I have to
move onto other work which is incredibly frustrating as I will leave
behind a 'buggy' half finished wrapper.

Any input would be much appreciated.

:|

James


unsubscribe

2009-06-19 Thread Edwin Schepers




RE: Mystery concerning configuration SOLVED.

2009-06-19 Thread Eric Chamberlain
I have discovered the source of the problem.   We had split out the
log4net configuration from the web.config but with a redirection left
inside the web.config of the form:

 

log4net  file=other_config_directory/log4net.config /

 

The file at the end was of the correct syntax and could be used by
log4net but only to the extent that we used the param...  elements.  

 

I have modified the program to initialized log4net directly from the
split-out file and it works with full syntactical support.

 

Go figure, eh?

 

  == Eric ==

 



From: Eric Chamberlain eric.chamberl...@stratagen.com
To: log4net-user@logging.apache.org
Sent: Thursday, June 18, 2009 6:41:51 PM
Subject: Mystery concerning configuration

Greetings all,

 

I have an appender which works fine if specified with generic XML but
not when specified with conventional log4net terms in the configuration.

 

Examples should help:

 

The following works:

 

  appender name=LogServiceAppender

type=log4net.Appender.RollingFileAppender

param name=File

   value=myfile.log /

param name=AppendToFile

   value=true /

param name=MaxSizeRollBackups

   value=10/

param name=MaximumFileSize

   value=1MB/

param name=RollingStyle

   value=Size/

param name=StaticLogFileName

   value=true/

layout type=log4net.Layout.PatternLayout

  param name=ConversionPattern

 value=%d{ MMM dd HH:mm:ss} [%t] %-5p - %m%n /

/layout

  /appender

 

But the following does *not* work.  It fails to initialize (I turned on
the log4net debugging to see it).

 

  appender name=LogServiceAppender

type=log4net.Appender.RollingFileAppender

file value=myfile.log /

appendToFile value=true/

maxSizeRollBackups value=10/

maximumFileSize value=1MB/

rollingStyle value=Size/

staticLogFileName value=true/

layout type=log4net.Layout.PatternLayout

  conversionPattern value=%d{ MMM dd HH:mm:ss} [%t] %-5p -
%m%n /

/layout

  /appender

 

It appears that log4net initialization does not recognized its own XML
schema.   How is that possible?  

__

Eric Chamberlain



Getting AdoNetAppender parameters using Log4Net API

2009-06-19 Thread Cankut Eskin
Hello,

I've defined some extra parameters for AdoNetAppender in log4net config
file. Everything works fine.

Here is one of my extra parameters defined:

parameter
  parameterName value=@cachetid/
  dbType value=String/
  size value=36/
  layout type=log4net.Layout.RawPropertyLayout
key value=CachetID/
  /layout
/parameter

I wonder if there is some way in Log4Net API to get information about the
parameters defined for AdoNetAppender in the config file.

Any help will be appreciated.

Regards,

Cankut


Re: unsubscribe

2009-06-19 Thread Ron Grabowski

I think you need to send an email to a special unsubscribe address, not just a 
subject with unsubscribe as the subject.



- Original Message 
From: Laurence Hunter cazador7...@yahoo.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Friday, June 19, 2009 12:51:17 PM
Subject: unsubscribe


unsubscribe


Re: Getting AdoNetAppender parameters using Log4Net API

2009-06-19 Thread Ron Grabowski
Surprisingly the parameters collection isn't exposed publicly so you'd have to 
extend the built-in AdoNetAppender and expose them:

public class AdoNetAppender2 : AdoNetAppender
{
public AdoNetAppenderParameter[] GetParameters()
{
return m_parameters.CastAdoNetAppenderParameter().ToArray();
}
}

Then you can ask the repository for all the AdoNetAppender2 appenders and 
inspect their values:

var repository = LogManager.GetRepository();
foreach (var appender in repository.GetAppenders())
{
var adoNetAppender = appender as AdoNetAppender2;
if (adoNetAppender != null)
{
foreach (var parameter in adoNetAppender.GetParameters())
{
// parameter.ParameterName;
}
}
}





From: Cankut Eskin cankutes...@gmail.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Friday, June 19, 2009 1:13:13 PM
Subject: Getting AdoNetAppender parameters using Log4Net API

Hello,

I've defined some extra parameters for AdoNetAppender in log4net config file. 
Everything works fine.

Here is one of my extra parameters defined:

parameter
  parameterName value=@cachetid/
  dbType value=String/
  size value=36/
  layout type=log4net.Layout.RawPropertyLayout
key value=CachetID/
  /layout
/parameter

I wonder if there is some way in Log4Net API to get information about the 
parameters defined for AdoNetAppender in the config file.

Any help will be appreciated.

Regards,

Cankut


RE: Mystery concerning configuration SOLVED.

2009-06-19 Thread Eric Chamberlain
Actually, the file attribute on the log4net node is processed by the
.NET framework as a redirection to the given file.  The attribute tells
.NET to look for the actual definition of the section in the given file.
log4net should be oblivious to this but it is not.

 

The behavior seen is that log4net does read its configuration
information from the specified file *but* it doesn't recognize those
standard XML tags we log4net users have come to know and love.   All it
recognizes is param . . . /.   Of course, one could work around
this--no functionality is prevented by this behavior--but it is rather
awkward and unfriendly to work that way (especially if you're trying to
do something like use schema directives for intellisense-like help).

It is also much more readable to use the standard log4net schema and
understandable to people who come onboard the project from other
projects which have also used log4net.

 

The take-away from this experience for me is that web.config
redirections do not work nicely for log4net configuration. Though one
can make them work, they exact a penalty.  Better it is to just directly
name that separate log4net config file when one initializes log4net.

 

BTW,   the best intellisense log4net schema I have found so far is
from csharptest.net and is expressed as follows:

 

log4net
xsi:noNamespaceSchemaLocation=http://csharptest.net/downloads/schema/lo
g4net.xsd

 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;

 

If there is another one better, I would like to hear about it.
Specifically, it would be nice if I could find such a schema at
logging.apache.org !

 

 == Eric ==

 

From: Ron Grabowski [mailto:rongrabow...@yahoo.com] 
Sent: Friday, June 19, 2009 1:49 PM
To: Log4NET User
Subject: Re: Mystery concerning configuration SOLVED.

 

Log4net doesn't process the file attribute. I'm not sure how you're
using it. These two nodes are processed identically during
configuration:

 param name=Hello value=World /
 Hello value=World /



From: Eric Chamberlain eric.chamberl...@stratagen.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Friday, June 19, 2009 12:56:34 PM
Subject: RE: Mystery concerning configuration SOLVED.

I have discovered the source of the problem.   We had split out the
log4net configuration from the web.config but with a redirection left
inside the web.config of the form:

 

log4net  file=other_config_directory/log4net.config /

 

The file at the end was of the correct syntax and could be used by
log4net but only to the extent that we used the param...  elements.  

 

I have modified the program to initialized log4net directly from the
split-out file and it works with full syntactical support.

 

Go figure, eh?

 

  == Eric ==

 



From: Eric Chamberlain eric.chamberl...@stratagen.com
To: log4net-user@logging.apache.org
Sent: Thursday, June 18, 2009 6:41:51 PM
Subject: Mystery concerning configuration

Greetings all,

 

I have an appender which works fine if specified with generic XML but
not when specified with conventional log4net terms in the configuration.

 

Examples should help:

 

The following works:

 

  appender name=LogServiceAppender

type=log4net.Appender.RollingFileAppender

param name=File

   value=myfile.log /

param name=AppendToFile

   value=true /

param name=MaxSizeRollBackups

   value=10/

param name=MaximumFileSize

   value=1MB/

param name=RollingStyle

   value=Size/

param name=StaticLogFileName

   value=true/

layout type=log4net.Layout.PatternLayout

  param name=ConversionPattern

 value=%d{ MMM dd HH:mm:ss} [%t] %-5p - %m%n /

/layout

  /appender

 

But the following does *not* work.  It fails to initialize (I turned on
the log4net debugging to see it).

 

  appender name=LogServiceAppender

type=log4net.Appender.RollingFileAppender

file value=myfile.log /

appendToFile value=true/

maxSizeRollBackups value=10/

maximumFileSize value=1MB/

rollingStyle value=Size/

staticLogFileName value=true/

layout type=log4net.Layout.PatternLayout

  conversionPattern value=%d{ MMM dd HH:mm:ss} [%t] %-5p -
%m%n /

/layout

  /appender

 

It appears that log4net initialization does not recognized its own XML
schema.   How is that possible?  

__

Eric Chamberlain