Hi Dean,
Yes, even if smtpHost is specified in log4net.config, it still doesn't send.
Looking at SmtpAppender.cs in log4net, if I set smtpHost, it's the same code
path except that the Host property on SmtpClient is explicitly set. Knowing
that my test page works without setting the Host property explicitly, I can
tell that SmtpClient is picking up the right host from the <mailSettings>
section in my web.config file anyway:
<mailSettings>
<smtp>
<network host="relay-hosting.secureserver.net" port="25"/>
</smtp>
</mailSettings>
thanks,
Pete
-----Original Message-----
From: Dean Fiala [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 30, 2008 3:54 PM
To: 'Log4NET User'
Subject: RE: SmtpAppender not working on 3rd party hosting provider
Have you tried specifiying the smtp server to use in your log4net config
file...
<smtpHost value="mail.somedomain.com" />
-----Original Message-----
From: Pete Heist [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 30, 2008 9:05 AM
To: [email protected]
Subject: SmtpAppender not working on 3rd party hosting provider
I'm trying to figure out a situation where the SmtpAppender in my ASP.NET
3.5 application works properly on my development machine, but not on GoDaddy
shared hosting.
This might be easier, except that I can't see the output when
log4net.Internal.Debug = true at GoDaddy, because we have no access to, and
cannot add a listener for the System.Diagnostics output.
Some points:
- This works on my development machine with the same log4net.config.
However, in my web.config, of course, the SMTP server information is
different for development and production.
- Other logs from my RollingFileAppender appear properly, so log4net is
working.
- I know that I can send email, because a test page coded as follows in
production works:
{
string sFrom = "[EMAIL PROTECTED]";
string sTo = "[EMAIL PROTECTED]";
string sSubject = "test email to debug log4net on GoDaddy";
string sBody = "Why are log4net email notifications not working on
GoDaddy?";
MailMessage message = new MailMessage(sFrom, sTo, sSubject, sBody);
SmtpClient client = new SmtpClient();
client.Send(message);
}
- My appender in log4net.config looks like this:
<!-- sends an SMTP email (application log) -->
<appender name="ApplicationSmtpAppender"
type="log4net.Appender.SmtpAppender">
<from value="[EMAIL PROTECTED]" />
<to value="[EMAIL PROTECTED]" />
<subject value="Application log" />
<bufferSize value="50" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="WARN"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger
[%property{CurrentUser}] - %message%newline" />
</layout>
</appender>
Does anyone either know what this could be, or have another suggestion for
debugging it short of recompiling log4net with custom instrumenting code
that writes to a file?
thanks,
Pete