logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From UniqueDisplayName <fal...@bmico.com>
Subject Encrypt connection string in Log4Net configuration
Date Mon, 25 Jan 2016 20:54:32 GMT
I am trying to encrypt the log4net section to hide the username and password
in the connection string. To do this I'm using .Net's implementation of
encrypting the config file. The code is as follows:

Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");
ConfigurationSection section = config.GetSection("log4net");
if (!section.SectionInformation.IsProtected)
{
     
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
      config.Save();
}

The same approach can be seen in this post:
http://stackoverflow.com/questions/13688744/log4net-error-when-encrypting-config-file.
The beauty of this approach is that your application will decrypt the config
file at runtime, but for some reason this doesn't seem to be working with
log4net. It works fine with other 3rd parties such as Entity Framework. I'm
hoping I can get some advice on getting this to work. It feels like it's an
issue with log4net grabbing the config file before .Net has a chance to
decrypt it but I'm not quite sure how to fix it. Any advice would be great.

FWIW, this is an MVC site using .Net 4.5 and log4net 2.0.5.

Thank You,
UDN



--
View this message in context: http://apache-logging.6191.n7.nabble.com/Encrypt-connection-string-in-Log4Net-configuration-tp61227.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Mime
View raw message