Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-402

SMTP Appender keeps sending me emails

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 1.2.11
    • Fix Version/s: 1.2.11
    • Component/s: Appenders, Examples
    • Labels:
      None
    • Environment:
      Windows Server 2012
      IIS 7
      .Net 4 (ASP.Net) c#

      Description

      I want to receive an email from the system when a log level of ERROR or above occurs and i want to get the last 50 events of any level sent including the error event. for the life of me I can't figure out how to stop log4NET from sending me a email every 5 minutes with the past 50 events none of which is an error (errors are rear).

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
      <configSections>
      <section name="log4net" type="log4net.Config.Log4netConfigurationSectionHandler, log4net"/>
      </configSections>
      <log4net debug="false">
      <appender name="critical-smtp-appender" type="log4net.Appender.SmtpAppender">
      <from value="from@domain.com"/>
      <to value="techsupport@domain.com"/>
      <smtpHost value="mail.smtpserver.com"/>
      <EnableSsl value="false"/>
      <username value="no_reply@domain.com"/>
      <port value="26"/>
      <authentication value="Basic"/>
      <password value="********"/>
      <bufferSize value="50"/>
      <loosy value="true"/>
      <evaluator type="log4net.Core.LevelEvaluator">
      <threshold value="ERROR"/>
      </evaluator>
      <priority value="High"/>
      <subject type="log4net.Util.PatternString" value ="Web Service Incident Report: %property

      {log4net:HostName}

      "/>
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="Date: %date Level: %-5level Logger: %logger%newlineMessage: %message%newlineException: %exception%newlineStackTrace: %stacktracedetail%newline%newline"/>
      </layout>
      </appender>
      <appender name ="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="Logs\ServiceLogs.txt"/>
      <appendToFile value="true"/>
      <rollingStyle value="Composite"/>
      <datePattern value="yyyyMMdd"/>
      <maxSizeRollBackups value="30"/>
      <maximumFileSize value="5MB"/>
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value ="Date: %date Level: %-5level Logger: %logger%newlineMessage: %message%newlineException: %exception%newlineStackTrace: %stacktracedetail%newline%newline"/>
      </layout>
      </appender>
      <root>
      <level value="DEBUG"/>
      <appender-ref ref="RollingFileAppender"/>
      <appender-ref ref="critical-smtp-appender"/>
      </root>
      </log4net>
      </configuration>

      private static readonly ILog Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

      public ComplexWorkWcfService()
      {
      if (!log4net.LogManager.GetRepository().Configured)

      { var log4netpath = System.Web.Hosting.HostingEnvironment.MapPath("~/Log4net.config"); if (log4netpath == null) log4netpath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Log4net.config"); log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(log4netpath)); Logger.Debug(string.Format("logging configured.")); }

      }

      log4net version = 1.2.11.0

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Darion Mapp Darion Mapp
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: