Note that there are some explanatory texts on larger screens.

plurals
  1. POLog4Net Stops logging
    primarykey
    data
    text
    <p>I have a utility which runs all day for data conversions and synchronization. </p> <p>If the app stops running temporarily, it's not a big deal, but it has to log it's actions. I would rather the app fail than have it not log. I have come across a few posts which touch on the subject, but I cannot get any of the solutions to work.</p> <p>I need to set up a way to stop the application from running (depending on an app setting) and send out a warning email if Log4Net stops logging. </p> <p>I have this for my appender:</p> <pre><code>&lt;log4net&gt; &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt; &lt;errorHandler type="SomeApp.PresentationLayer.Log4NetErrorHandler" /&gt; &lt;file type="log4net.Util.PatternString" value="H:\SomeApp-%property{RegNo}-log.txt" /&gt; &lt;appendToFile value="true" /&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;header value="[START]" /&gt; &lt;footer value="[END]" /&gt; &lt;conversionPattern value="%date %-5level - %message%newline" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;!-- Setup the root category, add the appenders and set the default level --&gt; &lt;root&gt; &lt;level value="DEBUG" /&gt; &lt;appender-ref ref="LogFileAppender" /&gt; &lt;!-- &lt;appender-ref ref="A" /&gt; --&gt; &lt;/root&gt; </code></pre> <p></p> <p>And here's my Error Handler:</p> <pre><code>namespace SomeApp.PresentationLayer { class Log4NetErrorHandler : IErrorHandler { public bool HandleError(Exception ex) { //Trace.TraceError(ex.ToString()); ExceptionUtil.GetAndLogMessage(ex, "Log4Net Error in SomeApp", false, true); return false; } public void ProvideFault(Exception error, MessageVersion version, ref Message fault) { // Shield the unknown exception FaultException faultException = new FaultException( "Server error encountered. All details have been logged."); MessageFault messageFault = faultException.CreateMessageFault(); fault = Message.CreateMessage(version, messageFault, faultException.Action); } } } </code></pre> <p>No matter what I try, the exception handler never fires. I have the log file set to a mapped drive. While it's logging I disconnect the drive and it never throws an exception to my exception handler. Anyone see what I'm missing?</p> <p>I'm using c# .net 3.5 log4net 1.2.10</p> <p>Thanks for any help in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload