I'm not sure if this is a big problem, but it could be a subtle one. And multi-threading issues could come into play too. That could get tough to debug.
Baron
--
"I am as bad as the worst, but, thank God, I am as good as the best."
- Walt WhitmanOn Sat, 2 Apr 2005, Nicko Cadell wrote:
Baron,
The runtime provides SMTP support through the MailMessage. Microsoft have chosen to implement it using their CDO library. Usually CDO works fine, however it is possible for it to be disabled.
While it should be simple to implement a system that sends mail directly via port 25 I'm not sure it this is necessarily the best use of resources as CDO works out of the box.
If someone wants to look at doing this it may be best to make the mail sending functionality of the SmtpAppender pluggable between the current MailMessage and an independent implementation.
Nicko
-----Original Message----- From: Baron Schwartz [mailto:[EMAIL PROTECTED] Sent: 24 March 2005 14:27 To: Log4NET User Subject: RE: SmtpAppender not working
Thanks Nicko.
I have searched more on the various error messages and found that indeed it is a problem with CDO on my laptop. When I configure the logging on the production machines, it works fine. I'm not familiar with what CDO is or how/why it's not working on my laptop, other than maybe I borked it up when I turned off every non-essential service (I believe the Systems staff has all sorts of stuff running on the production servers... not my job).
I did try using the fully qualified name of the SMTP machine, and even its IP address; like I said I've had no problems with sending to that machine with the SMTP software I've written (telnet, too).
I looked through the source code for the SmtpAppender more. I'm not sure how many people would use the more advanced settings, such as sending through the credentials of the process under which log4net runs -- and I know it's bad to reinvent the wheel. But, just to play devil's advocate, is there any justification for an SMTP appender which sends via plain SMTP, without relying on System.Web.Mail? SMTP is trivial to implement, and this might ease the problems, and may even be more efficient as an appender. I saw a lot of griping on the Internet about this CDO issue, with no real resolutions. It sounds like there may be some Microsoftish "extend the standard" issues with CDO. But I'm no expert on it, as I said.
Baron
On Thu, 24 Mar 2005, Nicko Cadell wrote:
access the"The transport failed to connect to the server"
It looks like the CDO implementation on the machine cannotdomain name?mail server.
You config is fine for accessing an unauthenticated mail relay.
Can you try telneting directly into your mail server from the box running your app:
telnet madrid 25
Type in "HELO" the server should respond with some helpful message. Type "QUIT" to exit. Does this work? Have you tried specifying the smtpHost as a fully qualifiedor as an IP address? It may be that the CDO library cannotresolve thehttp://www.google.co.uk/search?q=transport+failed+to+connect+to+the+sename.
Are you running any local firewall software that may be blocking outbound connections, for some or all users or applications?
There seems to be several other people having the same problem with various fixes discussed here:
code, butrv er+CDO
Nicko
-----Original Message----- From: Baron Schwartz [mailto:[EMAIL PROTECTED] Sent: 21 March 2005 16:57 To: [email protected] Subject: SmtpAppender not working
Hi,
I've searched the web and read the manual and some of the([EMAIL PROTECTED]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 fileemail. The SMTPis bogus -- I'm using a real value), test code, and the error I'm getting in the console window when the log fails towhich requiresserver, madrid, is an open relay inside our firewall,not sureno 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'mproperties, it lookswhat they should be (the example config seems to be incomplete). Starting at SmtpAppender.cs, and looking at itsfind it outlike 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 canlog4net" />(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,%c line %L%n</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 %dthrown by the%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 beenBindingFlagstarget 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,byrefModifiers,invokeAttr, Object target, Object[] args, Boolean[]invokeAttr,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, BindingFlagsBinder 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)
