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 "Paul Speranza (JIRA)" <ji...@apache.org> on 2008/10/16 20:23:46 UTC

[jira] Created: (LOG4NET-180) SMTPAppender not sending all emails

SMTPAppender not sending all emails
-----------------------------------

                 Key: LOG4NET-180
                 URL: https://issues.apache.org/jira/browse/LOG4NET-180
             Project: Log4net
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 1.2.10
         Environment: Windows XP with SP2, Visual Studio 2008 with SP1, C#, WCF
            Reporter: Paul Speranza


I have a WCF IIS service application. hardly any of my SMTP emails are getting sent out. TO be sure that it isn't my SMTP server I created a console app that sends mail using System.Net.Mail and it works every time. I only have log4net configured for SmtpAppender.

Here is the config.


  <log4net>
    <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender" >
      <to value="to@email.com" />
      <from value="from@email.com" />
      <smtpHost value="127.0.0.1" />
      <subject value="An exception occurred in Services." />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>      
      <priority value="High" />
    </appender>
    <!--<root>
      <level value="ALL" />
      <appender-ref ref="SmtpAppender" />
    </root>-->
    <logger name="Services">
      <level value="All" />
      <appender-ref ref="SmtpAppender" />
    </logger>
  </log4net>

PLUS 

<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />

In my global asax I have

    void Application_Start(object sender, EventArgs e) 
    {
        log4net.Config.XmlConfigurator.Configure();

    }

In my service implementation I have 

    private static readonly log4net.ILog _Logger = log4net.LogManager.GetLogger("Services");

Where I am telling log4net to do its  magic is

        if (_Logger.IsErrorEnabled)
            _Logger.Error(formattedException, exception);

I have no idea what this could be. I am brand new to log4net also.

Thnaks




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LOG4NET-180) SMTPAppender not sending all emails

Posted by "James Shute (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4NET-180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640484#action_12640484 ] 

James Shute commented on LOG4NET-180:
-------------------------------------

Don't know if it's the issue here, but I've found when working with the SmtpClient class in .NET (which the SmtpAppender naturally does) then if you want the mails sent in a timely manner you need to set the ServicePoint.MaxIdleTime property on the SmtpClient object.  We've normally used 1000 (1 sec) and it all works quite happily.

A quick snoop on the SmtpAppender code seems to show there's no way to access this at present, so guess it would need a code change - maybe the best option would be to just add a property on SmtpAppender which is routed through to the SmtpClient object that gets created.

ps.  Whoever gets round to doing this may also want to modify the SendEmail method to have a "using" block for the MailMessge object, given it's an IDisposable object.

> SMTPAppender not sending all emails
> -----------------------------------
>
>                 Key: LOG4NET-180
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-180
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10
>         Environment: Windows XP with SP2, Visual Studio 2008 with SP1, C#, WCF
>            Reporter: Paul Speranza
>
> I have a WCF IIS service application. hardly any of my SMTP emails are getting sent out. TO be sure that it isn't my SMTP server I created a console app that sends mail using System.Net.Mail and it works every time. I only have log4net configured for SmtpAppender.
> Here is the config.
>   <log4net>
>     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender" >
>       <to value="to@email.com" />
>       <from value="from@email.com" />
>       <smtpHost value="127.0.0.1" />
>       <subject value="An exception occurred in Services." />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
>       </layout>      
>       <priority value="High" />
>     </appender>
>     <!--<root>
>       <level value="ALL" />
>       <appender-ref ref="SmtpAppender" />
>     </root>-->
>     <logger name="Services">
>       <level value="All" />
>       <appender-ref ref="SmtpAppender" />
>     </logger>
>   </log4net>
> PLUS 
> <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
> In my global asax I have
>     void Application_Start(object sender, EventArgs e) 
>     {
>         log4net.Config.XmlConfigurator.Configure();
>     }
> In my service implementation I have 
>     private static readonly log4net.ILog _Logger = log4net.LogManager.GetLogger("Services");
> Where I am telling log4net to do its  magic is
>         if (_Logger.IsErrorEnabled)
>             _Logger.Error(formattedException, exception);
> I have no idea what this could be. I am brand new to log4net also.
> Thnaks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LOG4NET-180) SMTPAppender not sending all emails

Posted by "Ron Grabowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4NET-180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12682365#action_12682365 ] 

Ron Grabowski commented on LOG4NET-180:
---------------------------------------

It sounds like a server issue. Have you tried enabling SmtpClient's internal debugging:

 Griping about System.Net.Email.SmptClient/MailMessage
 http://www.west-wind.com/weblog/posts/229457.aspx

or writing your own SmtpAppender that sends mail? SmtpAppender.SendEmail just creates an SmtpClient, sets properties, then calls Send(MailMessage).

> SMTPAppender not sending all emails
> -----------------------------------
>
>                 Key: LOG4NET-180
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-180
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10
>         Environment: Windows XP with SP2, Visual Studio 2008 with SP1, C#, WCF
>            Reporter: Paul Speranza
>
> I have a WCF IIS service application. hardly any of my SMTP emails are getting sent out. TO be sure that it isn't my SMTP server I created a console app that sends mail using System.Net.Mail and it works every time. I only have log4net configured for SmtpAppender.
> Here is the config.
>   <log4net>
>     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender" >
>       <to value="to@email.com" />
>       <from value="from@email.com" />
>       <smtpHost value="127.0.0.1" />
>       <subject value="An exception occurred in Services." />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
>       </layout>      
>       <priority value="High" />
>     </appender>
>     <!--<root>
>       <level value="ALL" />
>       <appender-ref ref="SmtpAppender" />
>     </root>-->
>     <logger name="Services">
>       <level value="All" />
>       <appender-ref ref="SmtpAppender" />
>     </logger>
>   </log4net>
> PLUS 
> <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
> In my global asax I have
>     void Application_Start(object sender, EventArgs e) 
>     {
>         log4net.Config.XmlConfigurator.Configure();
>     }
> In my service implementation I have 
>     private static readonly log4net.ILog _Logger = log4net.LogManager.GetLogger("Services");
> Where I am telling log4net to do its  magic is
>         if (_Logger.IsErrorEnabled)
>             _Logger.Error(formattedException, exception);
> I have no idea what this could be. I am brand new to log4net also.
> Thnaks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LOG4NET-180) SMTPAppender not sending all emails

Posted by "Ron Grabowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4NET-180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646740#action_12646740 ] 

Ron Grabowski commented on LOG4NET-180:
---------------------------------------

What happens when you add this to the appender:

 <bufferSize value="1" />

> SMTPAppender not sending all emails
> -----------------------------------
>
>                 Key: LOG4NET-180
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-180
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10
>         Environment: Windows XP with SP2, Visual Studio 2008 with SP1, C#, WCF
>            Reporter: Paul Speranza
>
> I have a WCF IIS service application. hardly any of my SMTP emails are getting sent out. TO be sure that it isn't my SMTP server I created a console app that sends mail using System.Net.Mail and it works every time. I only have log4net configured for SmtpAppender.
> Here is the config.
>   <log4net>
>     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender" >
>       <to value="to@email.com" />
>       <from value="from@email.com" />
>       <smtpHost value="127.0.0.1" />
>       <subject value="An exception occurred in Services." />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
>       </layout>      
>       <priority value="High" />
>     </appender>
>     <!--<root>
>       <level value="ALL" />
>       <appender-ref ref="SmtpAppender" />
>     </root>-->
>     <logger name="Services">
>       <level value="All" />
>       <appender-ref ref="SmtpAppender" />
>     </logger>
>   </log4net>
> PLUS 
> <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
> In my global asax I have
>     void Application_Start(object sender, EventArgs e) 
>     {
>         log4net.Config.XmlConfigurator.Configure();
>     }
> In my service implementation I have 
>     private static readonly log4net.ILog _Logger = log4net.LogManager.GetLogger("Services");
> Where I am telling log4net to do its  magic is
>         if (_Logger.IsErrorEnabled)
>             _Logger.Error(formattedException, exception);
> I have no idea what this could be. I am brand new to log4net also.
> Thnaks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.