logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From talktopete <talktop...@gmail.com>
Subject Re: Trying to set up an EXTREMELY SIMPLE event log feature... and failing terribly! Please help a newbie
Date Wed, 12 Nov 2008 00:18:45 GMT

By golly, you got it!!!

By changing my layout to log4net.Layout.SimpleLayout, it started working!
The problem was with the layout format:
------------------------------------------------------------------------------ 
"%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"
------------------------------------------------------------------------------
something in there caused the logger to fail. What is annoying is how
silently it failed, I wish there was an option to make log4net throw
verbose, easy-to-understand exceptions!

I got the layout string from various examples on the google. Go figure
someone posted code that fails...


Ron Grabowski wrote:
> 
> The first thing I would is to make sure log4net itself is working. Your
> config file runs correctly when I add a ConsoleAppender:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <configSections>
>     <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
>   </configSections>
>   <log4net>
>     <appender name="EventLogAppender"
> type="log4net.Appender.EventLogAppender" >
>       <layout type="log4net.Layout.SimpleLayout" />
>     </appender>
>     <appender name="ConsoleAppender"
> type="log4net.Appender.ConsoleAppender" >
>       <layout type="log4net.Layout.SimpleLayout" />
>     </appender>
>     <root>
>       <level value="ALL" />
>       <appender-ref ref="EventLogAppender" />
>       <appender-ref ref="ConsoleAppender" />
>     </root>
>   </log4net>
> </configuration>
> 
> I can also see the entries in the Event Log. Internal debugging:
> 
>   <appSettings>
>     <add key="log4net.Internal.Debug" value="true" />
>   </appSettings>
> 
> didn't show any problems. Do you get an exceptions when internal debugging
> is turned on? From what I can tell it looks like there's something wrong
> with the machine its running on.
> 
> 
> 
> ----- Original Message ----
> From: talktopete <talktopete@gmail.com>
> To: log4net-user@logging.apache.org
> Sent: Tuesday, November 11, 2008 4:34:20 PM
> Subject: Trying to set up an  EXTREMELY SIMPLE event log feature... and
> failing terribly! Please help a newbie
> 
> 
> Hi and thanks in advance for the help.
> I'm tearing my hair out over here trying to get this to work: a siple
> logger
> that writes to the application section of the event log.
> 
> This is using log4net 1.2.10.0
> Here is the app config:
> --------------------------------------------------------------
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <configSections>
>     <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
>   </configSections>
> 
>   <log4net>
>     <appender name="EventLogAppender"
> type="log4net.Appender.EventLogAppender" >
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
>       </layout>
>     </appender>
>     <root>
>       <level value="ALL" />
>       <appender-ref ref="EventLogAppender" />
>     </root>
>   </log4net>
> </configuration>
> --------------------------------------------------------------------
> here is my code:
>   log4net.Config.XmlConfigurator.Configure();
>   logger = LogManager.GetLogger("EventLogAppender");
>   logger.Error("test");
> -------------------------------------------------------------------
> 
> No errors, nothing happens! I notice that there are no appenders.
> nothing is written to the event log.
> 
> I am tearing my hair out trying to figure out what is going on, can
> somebody
> help?
> -- 
> View this message in context:
> http://www.nabble.com/Trying-to-set-up-an--EXTREMELY-SIMPLE-event-log-feature...-and-failing-terribly%21-Please-help-a-newbie-tp20448428p20448428.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
> 
> 

-- 
View this message in context: http://www.nabble.com/Trying-to-set-up-an--EXTREMELY-SIMPLE-event-log-feature...-and-failing-terribly%21-Please-help-a-newbie-tp20448428p20451489.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Mime
View raw message