Quantcast
Channel: BugNET Issue Tracker (Moved to GitHub)
Viewing all articles
Browse latest Browse all 2179

Commented Unassigned: Support for SSL and authentication in LoggingManager mail server settings [115]

$
0
0
The ConfigureEmailLoggingAppender function in LogiingManager.cs should use the same SMTP mail server settings as in the rest of the BugNet application.

You will need to upgrade to the latest log4net.dll version (1.2.11) to get SSL SMTP server support. Also take care of the strong name key throughout the solution when selecting the version with the new key:
[Download Apache log4net](http://logging.apache.org/log4net/download_log4net.cgi)

The ConfigureEmailLoggingAppender function could be updated as follows:

```
public static void ConfigureEmailLoggingAppender()
{
var hier =
(log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();

if (hier == null) return;

var appender = (SmtpAppender)hier.Root.GetAppender("SmtpAppender") ?? new SmtpAppender();

appender.Name = "SmtpAppender";
appender.From = HostSettingManager.Get(HostSettingNames.HostEmailAddress, string.Empty);
appender.To = HostSettingManager.Get(HostSettingNames.ErrorLoggingEmailAddress, string.Empty);
appender.Subject = "BugNET Error";
appender.SmtpHost = HostSettingManager.SmtpServer;
appender.Port = int.Parse(HostSettingManager.Get(HostSettingNames.SMTPPort));
appender.Authentication = SmtpAppender.SmtpAuthentication.None;
appender.Username = string.Empty;
appender.Password = string.Empty;
appender.EnableSsl = Boolean.Parse(HostSettingManager.Get(HostSettingNames.SMTPUseSSL));

if (Convert.ToBoolean(HostSettingManager.Get(HostSettingNames.SMTPAuthentication)))
{
appender.Authentication = SmtpAppender.SmtpAuthentication.Basic;
appender.Username = String.Format("{0}\\{1}", HostSettingManager.Get(HostSettingNames.SMTPDomain, string.Empty), HostSettingManager.Get(HostSettingNames.SMTPUsername, string.Empty) );
appender.Password = HostSettingManager.Get(HostSettingNames.SMTPPassword, string.Empty);
}

//HostSettingManager.Get(HostSettingNames.SMTPAuthentication);
appender.Priority = System.Net.Mail.MailPriority.High;
appender.Threshold = log4net.Core.Level.Error;
appender.BufferSize = 0;

//create patternlayout
var patternLayout = new
log4net.Layout.PatternLayout("%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline");

patternLayout.ActivateOptions();
appender.Layout = patternLayout;
appender.ActivateOptions();

//add appender to root logger
hier.Root.AddAppender(appender);
}
```
Comments: OK, now it's working without the <bindingRedirect/> element in the Web.config, Apparently not all dependent assemblies are in the references list in the main BugNET_WAP.csproj file, hence they were missing when building the deployment package, and not updated on the target web site. So I added all Http.*.dll and Provider.*.dll assemblies as references in the BugNET_WAP.csproj file. I also tested with the log4net 1.2.11 with the new strong name and it's also working now: * replaced "PublicKeyToken=1b44e1d426115821" with "PublicKeyToken=669e0ddf0bb1aa2" in all *.csproj files * Edit hint paths to point to correct relative subfolder "..\packages\log4net.1.2.11\bin\net\4.0\release\log4net.dll" * Clean and rebuild the solution for the Debug and Release configurations * empty the "Temporary ASP.NET Files" folder * test ;-)

Viewing all articles
Browse latest Browse all 2179

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>