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

  • Home
  • SEARCH
  • 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 6026083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:23:39+00:00 2026-05-23T04:23:39+00:00

I’m using log4net for logging and sending e-mails. I need to send different e-mails

  • 0

I’m using log4net for logging and sending e-mails. I need to send different e-mails with different configurations according to different processes. For example, when one of my methods finishes processing, it sends a mail to X, and when my service finishes successfully, it sends another mail to Y.
I think I need to use different appenders with filters, but I can’t get to configure them properly.

I tried the following and tried to apply a StringMatchFilter so that messages containing “mandatory” will not be delivered to Y and messages containing “successfully” will not be delivered to X, but with no luck. I am also not sure whether this kind of filtering is the right way to do this kind of configuration.

<log4net>

    <appender name="ManFieldMailAppender" type="log4net.Appender.SmtpAppender,log4net">
        <evaluator type="log4net.Core.LevelEvaluator">
            <threshold value="WARN"/>
        </evaluator>
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="WARN" />
            <acceptOnMatch value="true" />
        </filter>
        <filter type="log4net.Filter.StringMatchFilter">
            <stringToMatch value="successfully" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.DenyAllFilter" />
        <to value="x@xxx.com" />
        <from value="aaa@aaa.com" />
        <subject value="Products not made online" />
        <smtpHost value="Host" />
        <authentication value="1"/>
        <username value="uid" />
        <password value="pwd" />
        <port value="25"/>
        <bufferSize value="1" />
        <lossy value="false" />
        <layout type="log4net.Layout.PatternLayout,log4net">
            <conversionPattern value="%newline %date %message%newline%newline%newline" />
        </layout>
    </appender>

    <appender name="ServiceFinishedMailAppender" type="log4net.Appender.SmtpAppender,log4net">
        <evaluator type="log4net.Core.LevelEvaluator">
            <threshold value="WARN"/>
        </evaluator>
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="WARN" />
            <acceptOnMatch value="true" />
        </filter>
        <filter type="log4net.Filter.StringMatchFilter">   
            <stringToMatch value="mandatory" />
            <acceptOnMatch value="false" />
        </filter>
        <filter type="log4net.Filter.DenyAllFilter" />
        <to value="y@yyy.com" />
        <from value="bbb@bbb.com" />
        <subject value="Product Publish Service has successfully finished operating" />
        <smtpHost value="Host" />
        <authentication value="1"/>
        <username value="uid" />
        <password value="pwd" />
        <port value="25"/>
        <bufferSize value="1" />
        <lossy value="false" />
        <layout type="log4net.Layout.PatternLayout,log4net">
            <conversionPattern value="%newline %date %message%newline%newline%newline" />
        </layout>
    </appender>

    <root>
        <appender-ref ref="ManFieldMailAppender" />
        <appender-ref ref="ServiceFinishedMailAppender"/>
    </root>

</log4net>

What do you think the problem is?

Thank you.

  • 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-05-23T04:23:40+00:00Added an answer on May 23, 2026 at 4:23 am

    First, evaluator tells buffering appenders when to flush. From the look of your configuration I don’t think you’re buffering. (so you can get rid of the bufferSize and lossy parameters, too). I see your appender filter chains have the required DenyAllFilters. But, your root logger configuration is showing no levels, try adding

    <root>
        <level value="ALL" />
        <!-- appender-refs as normal -->
    </root>
    

    In general, I wouldn’t make the decision to log to a particular appender based on the message text. It looks like you have a high-level service class for one of the operations. If you have the same thing for the other messages that need to be sent, and you’re naming your loggers by typename, you can specify an appender per logger.

    <logger name="MyCompany.Product.Whatever">
        <level value="WARN" />
        <appender name="ManFieldMailAppender" type="...">
            <!-- the rest of the configuration, without filtering goes here -->
        </appender>
    </logger>
    
    <logger name="MyCompany.Services.Publish">
        <level value="WARN" />
        <appender name="ServiceFinishedMailAppender" type="...">
            <!-- the rest of the configuration, without filtering goes here -->
        </appender>
    </logger>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

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.