Log4net Configuration Stmpappender

Source: Internet
Author: User

Directory

Log4net Configuration Stmpappender 1

1. Preface 1

2. Detailed Configuration 1

1.StmpAppender Configuration 1

2.Root Configuration 2

3. More Options 3

1. Preface

Problem Description: Although the log can be logged through the file, but the information can not be notified to the maintenance personnel in real time, and Log4net provides a mail log

The benefits can be considered in the following situations:

Weekend, holiday, the program has a problem, recorded the file log, but can not notify the OPS personnel, at this time, the use of mail logs or text message log can be a good response!

Reference documents:

Http://www.cnblogs.com/anderslly/archive/2007/03/09/log4netconfigsamples.html

2. Detailed configuration 1. Stmpappender Configuration
  1. <appender name= "Smtpappender" type="log4net. Appender.smtpappender ">
  2. <authentication Value= "Basic" />
  3. < to value= "yourqqnumber@qq. com" />
  4. < from value= " yourqqnumber @qq. com" />
  5. <username Value= " yourqqnumber " />
  6. <password value= " yourqq pwd" />
  7. <subject value= "EBAY API ERROR" />
  8. <smtphost value= "smtp.qq.com" />
  9. <buffersize value= "465" />
  10. <lossy Value= "true" />
  11. <evaluator type= "log4net. Core.levelevaluator ">
  12. <threshold value= "ERROR"/>
  13. </Evaluator>
  14. <layout type= "log4net. Layout.patternlayout ">
  15. <conversionpattern value= "%newline%date [%thread]%-5level%logger [%PROPERTY{NDC}]-% Message%newline%newline%newline " />
  16. </Layout>
  17. </appender>

The above configuration effect, only the error level of the message to enter the mailbox!

2.Root Configuration
  1. <root>
  2. < level Value= "INFO" />
  3. <appender-ref ref= "Consoleappender" />
  4. <appender-ref ref= "Rollingfileappenderall" />
  5. <appender-ref ref= "Adonetappender" />
  6. <appender-ref ref= "Smtpappender" />
  7. </root>

Execution Result:

3. More Options

You can set a CC, reply address, and so on.

API Documentation:

Http://logging.apache.org/log4net/release/sdk/log4net.Appender.SmtpAppenderMembers.html

Log4net Configuration Stmpappender

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.