This IS a console application, .net 3.5, and the app.config file is set to
always copy on build, so that rules out number one.
I ran the code you suggested, and yielded this information:
---------------------------------------------------------------------------
Root Information:
Name: log4net-default-repository Threshold: ALL
Root Appenders: EventLogAppender,
Hierarchy Appenders:
Appender: EventLogAppender Type: log4net.Appender.EventLogAppender
Loggers:
EventLogAppender Additivity: True Level: null
--------------------------------------------------------------------------
Does anything in there jump out at you, such as the "Level" perhaps?
Francine Taylor wrote:
>
> You didn't mention what type of application this is being run from. I
> have two suggestions for error checking, don't know if they will help.
>
> The first is that if you are getting errors, you won't be able to see
> them unless you are running from a console application (or unless you
> set up a trace appender to grab the errors, I haven't done that so
> you'll have to google for it). This will tell you if the problem is
> with the error logging itself.
>
> The second is a method which will tell you how your log4net is
> configured. It's written in C#, so you may need to translate. This
> should tell you if it is your log4net configuration process which is
> going astray.
>
> public static string GetHierarchyInformation() {
>
> Hierarchy hier = (Hierarchy)LogManager.GetRepository();
>
> StringBuilder sb = new StringBuilder();
>
> // first, look for it in the root
> sb.AppendLine("Root Information:");
> sb.Append(" Name: " + hier.Name);
> sb.AppendLine(" Threshold: " + hier.Threshold.ToString());
>
> sb.Append(" Root Appenders: ");
> foreach (IAppender a in hier.Root.Appenders) {
> sb.Append(a.Name + ", ");
> }
> sb.AppendLine("");
> sb.AppendLine("Hierarchy Appenders:");
> foreach (IAppender a in hier.GetAppenders()) {
> sb.AppendLine(FormatAppenderLine(a));
> }
>
> sb.AppendLine("Loggers:");
> foreach (ILogger l in hier.GetCurrentLoggers()) {
>
> Logger log = (Logger)l;
> sb.Append(" " + log.Name);
> sb.Append(" Additivity: " + log.Additivity.ToString());
>
> sb.Append(" Level: ");
> if (log.Level == null) {
> sb.Append("null");
> }
> else {
> sb.Append(log.Level.ToString());
> }
> sb.AppendLine("");
> foreach (IAppender appender in log.Appenders) {
> sb.AppendLine(FormatAppenderLine(appender));
> }
> }
> return sb.ToString();
> }
> private static string FormatAppenderLine(IAppender appender) {
> StringBuilder sb2 = new StringBuilder();
> sb2.Append(" Appender: " + appender.Name);
> sb2.Append(" Type: " + appender.GetType().ToString());
>
> if (appender is log4net.Appender.FileAppender) {
> FileAppender app = (FileAppender)appender;
> sb2.Append(" File: " + app.File);
> }
> else if (appender is log4net.Appender.RollingFileAppender) {
> RollingFileAppender app = (RollingFileAppender)appender;
> sb2.Append(" File: " + app.File);
> }
> else if (appender is log4net.Appender.SmtpAppender) {
> SmtpAppender app = (SmtpAppender)appender;
> sb2.Append(" To: " + app.To);
> }
> return sb2.ToString();
> }
>
>
> -----Original Message-----
> From: talktopete [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 11, 2008 1:34 PM
> To: [email protected]
> 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-fe
> ature...-and-failing-terribly%21-Please-help-a-newbie-tp20448428p2044842
> 8.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
> ==========================================
> NOTICE: The contents of this e-mail message and any attachments are
> intended solely for the addressee(s) named in this message. This
> communication is intended to be and to remain confidential. If you are not
> the intended recipient of this message, or if this message has been
> addressed to you in error, please immediately alert the sender by reply
> e-mail and then delete this message and its attachments. Do not deliver,
> distribute or copy this message and/or any attachments and if you are not
> the intended recipient, do not disclose the contents or take any action in
> reliance upon the information contained in this communication or any
> attachments.
> Thank you
>
>
--
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-tp20448428p20449791.html
Sent from the Log4net - Users mailing list archive at Nabble.com.