Hi,

I've searched the web and read the manual and some of the code, but feel
free to point me somewhere there's an answer... I can't find much on this.

My SmtpAppender isn't able to connect to the smtpHost.  I'm on Windows
using MS framework v1.1.  Here's my config file ([EMAIL PROTECTED] is bogus -- 
I'm
using a real value), test code, and the error I'm getting in the console
window when the log fails to email.  The SMTP server, madrid, is an open
relay inside our firewall, which requires no authentication or anything.
I send mail with it from a bunch of other apps.

One thing I did notice, is that apparently there are some other parameters
I could be putting in the config file, but I'm not sure what they should
be (the example config seems to be incomplete).  Starting at
SmtpAppender.cs, and looking at its properties, it looks like username,
password etc *could* be put in the config file.  I didn't read through
enough of the code to determine what the parameters would be named,
because they wouldn't be necessary for this application, but if someone
points me to how I can find it out (short of stepping through the code)
I'm happy to update the example, or augment it with a more complete
example.

Thanks for any help.

--- Snip ---
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    </configSections>
    <log4net>
        <appender name="SmtpAppender"
type="log4net.Appender.SmtpAppender">
            <to value="[EMAIL PROTECTED]" />
            <from value="[EMAIL PROTECTED]" />
            <subject value="Baaaaad error" />
            <smtpHost value="madrid" />
            <bufferSize value="4" />
            <lossy value="true" />
            <evaluator type="log4net.Core.LevelEvaluator">
                <threshold value="WARN"/>
            </evaluator>
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%-5p %-20t %d %c line %L%n
%m%n" />
            </layout>
        </appender>
        <root>
            <appender-ref ref="SmtpAppender" />
        </root>
    </log4net>
    <appSettings>
    </appSettings>
</configuration>
--- Snip ---
using System;
using log4net;
using log4net.Config;
namespace TestHarness {
    public class TestHarness {
        static readonly ILog log = LogManager.GetLogger(typeof(TestHarness));
        public static void Main(string[] args) {
            XmlConfigurator.Configure();
            log.Warn("hey, this is an error!");
        }
    }
}
--- Snip ---
log4net:ERROR [SmtpAppender] Error occurred while sending e-mail
notification.
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Ref
lection.TargetInvocationException: Exception has been thrown by the target
of an
 invocation. ---> System.Runtime.InteropServices.COMException
(0x80040213): The
transport failed to connect to the server.

   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[]
namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Bind
er binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureI
nfo culture, String[] namedParameters)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder bind
er, Object target, Object[] args)
   at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, St
ring methodName, Object[] args)
   at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
method
Name, Object[] args)
   --- End of inner exception stack trace ---
   at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
method
Name, Object[] args)
   at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
   at System.Web.Mail.SmtpMail.Send(MailMessage message)
   at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)

Reply via email to