DutchgirlRN
New Member
To perform error logging for my WebAPI application, I am using Log4net. I have two log4net appenders, a SmtpEmail appender that uses another server equipped with smtp to send the error-notice email, and a FileAppender directed to a local .txt file. My issue is that my FileAppender is logging everything in my log.txt file as expected, but the SmtpEmail appender is not working. Emails are not received, and I don't get any error messages. Something I noticed is that it would take a long time for DOMConfigurator.Configure() to return, and after it returns, I am often left with many of the same running processes continuing off that return. Any ideas as to what's wrong, or anything I can do to monitor if the calls to the smtp server (referred to below as "baz.bar.com") is going through?Here is the relevant log4net code in the .config file:\[code\]<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /><log4net><appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="http://stackoverflow.com/questions/12788513/log-file.txt" /> <appendToFile value="http://stackoverflow.com/questions/12788513/true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="http://stackoverflow.com/questions/12788513/%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout></appender><appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> <to value="http://stackoverflow.com/questions/12788513/[email protected]" /> <from value="http://stackoverflow.com/questions/12788513/[email protected]" /> <subject value="http://stackoverflow.com/questions/12788513/Write to AX Error" /> <smtpHost value="http://stackoverflow.com/questions/12788513/baz.bar.com" /> <bufferSize value="http://stackoverflow.com/questions/12788513/1" /> <lossy value="http://stackoverflow.com/questions/12788513/false" /> <evaluator type="log4net.Core.LevelEvaluator"> <threshold value="http://stackoverflow.com/questions/12788513/WARN"/> </evaluator> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="http://stackoverflow.com/questions/12788513/%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" /> </layout></appender><root> <level value ="http://stackoverflow.com/questions/12788513/DEBUG" /> <appender-ref ref ="FileAppender"/> <appender-ref ref ="SmtpAppender"/></root>\[/code\]I am using Unity. I doubt this is the issue, since my FileAppender is working, but here is the code regardless:\[code\] private static IUnityContainer BuildUnityContainer() { var container = new UnityContainer(); container.RegisterType<ILog>().RegisterInstance(LogManager.GetLogger(typeof(ILog))); return container; } private ILog _log; public LERService(ILog log) { _log = log; }\[/code\]Here are my calls to the log within a function of LERService:\[code\] catch(Exception e) { _log.Fatal("Cannot submit to client with following exception: " + e.Message, e); }\[/code\]