What would the return code be if you had 3 appenders and 1 of them failed? Is that considered success?
nlog can be configured to throw exceptions: <nlog autoRefresh="true" throwExceptions="true"> I don't know if that means it throws exception just during its startup or during the course of general logging. I always have log4net in debug mode and capture its startup log to a log4net.txt file that is in the same directory as my other FileAppenders. I would imagine you could capture the output to a memory stream and do some simple searches for strings like (I think this indicates that at least one appender has been initialized successfully...I could be wrong): log4net: DOMConfigurator: Hierarchy Threshold [] I agree that it would be nice to know if none of the appenders could be initialized. I also agree with Nicko that the logger shouldn't throw exceptions and prevent your application from working. - Ron --- Adrian Walls <[EMAIL PROTECTED]> wrote: > Niall, > > We wanted to use log4net in an application we are developing. I have > > previously used log4j with no issues whatsoever but this causes us a > big > problem. This is due to the fact that we cannot determine if logging > is > actually taking place or not. We were hoping that we could catch > this > as an exception to the event log to indicate that there is a problem > with the logging. Otherwise we have no indication that there is a > problem other than constantly monitoring the log files for activity. > > It would be nice even if this returned a return code to indicate if > it > was successful or not. Least that way we would know logging is > active, > otherwise we could log to another source. > > Regards, > Adrian. > > > > Niall Daley wrote: > > >Adrian, > > ConfigureAndWatch does not throw an exception if there is an error > >in the config file, as this could have unforeseen effects on the > >application using it. Currently there is no simple way to determine > >whether log4net configuration has succeeded, but there is a bug > raised > >(http://issues.apache.org/jira/browse/LOG4NET-2) regarding this. > > > > Niall Daley > > > >On Wed, 16 Mar 2005, Adrian Walls wrote: > > > > > > > >>Hi, > >> > >>I am using the log4net 1.2 framework in my application. I am using > the > >>DOMConfigurator.ConfigureAndWatch(FileInfo) to read and monitor an > >>external configuration file. See code below which I us to start my > logger. > >> > >> Private Sub startLogger() > >> Dim sr > >> Try > >> 'Start Application Logger > >> DOMConfigurator.ConfigureAndWatch(log4netConfig) > >> Catch e As Exception > >> sr = New StreamWriter("C:\Log4NetErrorStartLogger.log") > >> sr.WriteLine("Exception: " + e.Message()) > >> sr.Close() > >> End Try > >> > >>However if there is an issue with the config file (if for example I > >>remove a brace from one of the XML tags to throw an parsing > exception) > >>then log4net will simply not log anything. But it does not throw > an > >>exception to indicate that there is something wrong, should it not > >>catch exceptions thrown by the DOMConfigurator and write it to the > >>stream writer log file as configured as above. > >> > >>Or is there some issue with my code above. Any help which can shed > some > >>light on this issue will be greatly appriciated. > >> > >>Regards, > >>Adrian > >> > >> > >> > >> > >> > > > > > > >
