You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Darion Mapp (JIRA)" <ji...@apache.org> on 2013/10/22 23:17:41 UTC

[jira] [Comment Edited] (LOG4NET-402) SMTP Appender keeps sending me emails

    [ https://issues.apache.org/jira/browse/LOG4NET-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13802265#comment-13802265 ] 

Darion Mapp edited comment on LOG4NET-402 at 10/22/13 9:16 PM:
---------------------------------------------------------------

Could the following code in the class de-constructor (see below) be causing the emails to be sent? In the setup stated above would calling flush on the smtp appender trigger the email or would it treat this as an internal log full event and just discard the unwanted DEBUG and INFO entries given that the evaluator was not triggered? 

ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
var logger = log.Logger as Logger;
if (logger != null)
{
	foreach (IAppender appender in logger.Appenders)
	{
		var buffered = appender as BufferingAppenderSkeleton;
		if (buffered != null)
		{
			buffered.Flush(); //Can this be done with a smtp appender and not get a email. This is needed for the other file appenders. 
		}
		
	}
}


was (Author: darion mapp):
Could the following code in the class de-constructor (see below) be causing the emails to be sent? In the setup stated above would calling flush on the smtp appender trigger the email or would it treat this as an internal log full event and just discard the unwanted DEBUG and INFO entries given that the evaluator was not triggered? 

ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
var logger = log.Logger as Logger;
if (logger != null)
{
	foreach (IAppender appender in logger.Appenders)
	{
		var buffered = appender as BufferingAppenderSkeleton;
		if (buffered != null)
		{
			buffered.Flush(); //Can this be done with an smtp appender and not get a email. This is needed for the other file appenders. 
		}
		
	}
}

> 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="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



--
This message was sent by Atlassian JIRA
(v6.1#6144)