Note that there are some explanatory texts on larger screens.

plurals
  1. POlog4net smtpappender subject based on log level
    primarykey
    data
    text
    <p>Is it possible to configure log4net to have two smtp appenders - one that sends emails only when log level is >= WARN and second that sends everything, but never two on the same time.</p> <pre class="lang-xml prettyprint-override"><code>&lt;appender name="SmtpAppenderWarn" type="log4net.Appender.SmtpAppender"&gt; &lt;to value="to@domain.com" /&gt; &lt;from value="from@domain.com" /&gt; &lt;subject value="Import completed with warnings / errors" /&gt; &lt;smtpHost value="localhost" /&gt; &lt;bufferSize value="512" /&gt; &lt;lossy value="true" /&gt; &lt;evaluator type="log4net.Core.LevelEvaluator"&gt; &lt;threshold value="WARN"/&gt; &lt;/evaluator&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="SmtpAppenderSuccess" type="log4net.Appender.SmtpAppender"&gt; &lt;to value="to@domain.com" /&gt; &lt;from value="from@domain.com" /&gt; &lt;subject value="Import completed successfully" /&gt; &lt;smtpHost value="localhost" /&gt; &lt;bufferSize value="512" /&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="%date %-5level %logger: %message%newline" /&gt; &lt;/layout&gt; &lt;filter type="log4net.Filter.LevelMatchFilter"&gt; &lt;levelToMatch value="INFO" /&gt; &lt;/filter&gt; &lt;/appender&gt; </code></pre> <p>I my application I have:</p> <pre class="lang-cs prettyprint-override"><code>Log.Info("Importer is starting..."); //my logic //if warn Log.Warn("Warning..."); Log.Info("Import finished"); </code></pre> <p>So I'm using INFO all the time. Now when I encounter WARN both messages are being sent. I wish of course that the one with success info was not sent.</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.
    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