Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:33:41+00:00 2026-06-14T03:33:41+00:00

I have configured log4net with a RollingLogFileAppender and a SmtpAppender, with the intention of

  • 0

I have configured log4net with a RollingLogFileAppender and a SmtpAppender, with the intention of logging the DEBUG level to the RollingLogFileAppender and FATAL only to the SmtpAppender:

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
  <to value="test@test.com" />
  <from value="test@test.com" />
  <subject value="Fatal Error" />
  <smtpHost value="smtp.test.com" />
  <SMTPPort value="366"/>
  <Username value="test@test.com"/>
  <Password value="password"/>      
  <bufferSize value="1" />
  <lossy value="true" />
  <evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="FATAL"/>
  </evaluator>      
  <layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline"                             />
  </layout>
</appender>

<root>
  <level value="DEBUG" />
  <appender-ref ref="RollingLogFileAppender" />
  <appender-ref ref="SmtpAppender" />
</root>

This works perfectly until I increase the bufferSize. When I do this, all levels are sent via email and the log4net.Core.LevelEvaluator seems to be ignored. I have also tried using LevelRangeFilter and LevelMatchFilter but with these configured I seem to get no emails at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:33:42+00:00Added an answer on June 14, 2026 at 3:33 am

    The evaluator is not ignored, but it does not do what you expect: Your settings instruct the appender to put all log messages on a buffer and send an email only when a message with level FATAL is logged. If the buffer is full then the oldest messages are discarded (that is the lossy setting; without it you would also get an email as soon as the buffer is full).

    If you want to filter the messages then you need to use a filter. For instance like this:

    <filter type="log4net.Filter.LevelMatchFilter">
       <acceptOnMatch value="true" />
       <levelToMatch  value="FATAL" />
    </filter>
    <filter type="log4net.Filter.DenyAllFilter" />
    

    I am not sure though if I would consider my mail appender like this since I would want to get notified immediately if my application has a problem that it needs to log it with level FATAL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in my web.config: <log4net> <appender name=mainLog type=log4net.Appender.FileAppender> <file value=Log/Log.txt />
I have configured my application to use log4net as follows: <log4net> <appender name=SQL_Comandos type=log4net.Appender.AdoNetAppender>
I have a Log4Net RollingFileAppender that is configured as: <configuration> <configSections> <section name=log4net type=log4net.Config.Log4NetConfigurationSectionHandler,
I have the following log4net configuration: <log4net> <appender name=Console type=log4net.Appender.ConsoleAppender> <layout type=log4net.Layout.PatternLayout> <!-- Pattern
Have Log4Net configured in our application to use a date stamped name and a
I have a log4net file appender configured that all my log files should use:
I am using log4net DebugAppender (or TraceAppender). I have configured the appender like this:
I have configured log4Net EventLogAppender for Asp.Net 2.0. However it does not log anything.
I have two projects configured identically for log4net. One project logs fine; however, the
Odd one this. I am using NHibernate with one website. I have configured log4net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.