[
https://issues.apache.org/jira/browse/LOG4NET-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13802648#comment-13802648
]
Dominik Psenner commented on LOG4NET-402:
-----------------------------------------
I've taken a closer look to your configuration and noticed that you have
misspelled
"[Lossy|https://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Lossy.html]"
and written it as "Loosy". Thus your appender is not configured as Lossy. So
that's the reason why it keeps sending emails.
To answer your question I'm quoting the [SDK
reference|http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Flush_overload_1.html]:
{quote}If the appender is buffering in Lossy mode then the contents of the
buffer will NOT be flushed to the appender.{quote}
Thus in Lossy mode the above will not cause emails to be sent, but when not
configured to be Lossy it will flush the buffer and thus send emails. Maybe you
are interested in [this
overload|http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Flush_overload_2.html].
> SMTP Appender keeps sending me emails
> -------------------------------------
>
> Key: LOG4NET-402
> URL: https://issues.apache.org/jira/browse/LOG4NET-402
> Project: Log4net
> Issue Type: Bug
> Components: Appenders, Examples
> Affects Versions: 1.2.11
> Environment: Windows Server 2012
> IIS 7
> .Net 4 (ASP.Net) c#
> Reporter: Darion Mapp
> Priority: Minor
>
> 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="[email protected]"/>
> <to value="[email protected]"/>
> <smtpHost value="mail.smtpserver.com"/>
> <EnableSsl value="false"/>
> <username value="[email protected]"/>
> <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
--
This message was sent by Atlassian JIRA
(v6.1#6144)