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
