Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 81835 invoked from network); 18 Dec 2004 00:24:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Dec 2004 00:24:19 -0000 Received: (qmail 32339 invoked by uid 500); 18 Dec 2004 00:23:49 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 32051 invoked by uid 500); 18 Dec 2004 00:23:44 -0000 Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: "Log4NET User" Delivered-To: mailing list log4net-user@logging.apache.org Received: (qmail 31920 invoked by uid 99); 18 Dec 2004 00:23:42 -0000 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from web40407.mail.yahoo.com (HELO web40407.mail.yahoo.com) (66.218.78.104) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 17 Dec 2004 16:23:16 -0800 Received: (qmail 72941 invoked by uid 60001); 18 Dec 2004 00:23:14 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=1eNenAkTpcSkNrSTtnN2Si3FoDEzDaRhsPy1YupFJaBPKxZpcyEBPVskwbiIMXGrN5Hn9Cl9qz3B3NEqYFBwkBD2S4rBKrBesRzyfc1qV56Uul3jg1t4Vi8/CfuDZ/xnx9S4MG10IXEEqXlVLlTwHuMk6FnoiaVhLeJ4l2tyVbM= ; Message-ID: <20041218002314.72939.qmail@web40407.mail.yahoo.com> Received: from [24.33.239.147] by web40407.mail.yahoo.com via HTTP; Fri, 17 Dec 2004 16:23:14 PST Date: Fri, 17 Dec 2004 16:23:14 -0800 (PST) From: Ron Grabowski Subject: Re: How to use ErrorHandler To: Log4NET User In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N If you download and install this free program: http://www.sysinternals.com/ntw2k/freeware/debugview.shtml And setup log4net to run in Debug mode: You should be able to see your Appenders being initialized and/or the exceptions that are caused by incorrectly configured Appenders. This is how I log that information to a file in my Asp.Net application: if (log4netIsInDebugMode() == true) { // if log4net is in debug mode (useful for discovering why appenders are not working), it will // print out internal messages and errors to the System.Console and to System.Diagnostics.Trace; // the code below will capture log4net output and attempt to write it to a known writeable // directory; string physicalPathLogFile = Path.Combine(System.Web.HttpRuntime.AppDomainAppPath, LOG4NET_LOG_FILE); try { FileStream fileStream = new FileStream(physicalPathLogFile, FileMode.Create, FileAccess.Write ); if (fileStream != null && fileStream.CanWrite) { // this doesn't affect Trace.axd becuase Trace.axd is from System.Web.TraceContext // System.Diagnostics.Trace.Listeners.Clear(); System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(fileStream)); } } catch(SystemException ex) { // System.UnauthorizedAccessException - The exception that is thrown when the operating system denies access because of an I/O error or a specific type of security error. // log the message to a location that was the cause for the exception ??? System.Diagnostics.Trace.Write("log4net", "Unable to create log4net logger at [" + physicalPathLogFile + "]. Exception: " + ex.ToString()); } } log4net.Config.DOMConfigurator.Configure(); // make sure the complete log4net startup log appears System.Diagnostics.Trace.Flush(); - Ron --- "Collier, Mike" wrote: > How would I use the ErrorHandler property for an appender? For > example, > let's assume I'm using the ADONetAppender and for some reason it > fails > (i.e. unable to connect to the database server). I would like to not > loose the message. I was thinking that I could use the ErrorHandler > property to define another appender to use in this case. However, > I'm > not sure how to do this. Does anybody have any examples or ideas on > how > this might be accomplished. > > Thanks! > > > > > >