Adjust log4net logging severity

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adjust log4net logging severity

Justin Taylor

I’m working on a .NET Windows app, and I need the ability for the user to change the logging severity from within the app.  Right now, I have the logging severity set in my .config file, but that lives under Program Files so the user can’t modify that file.    I looked at the ConfigFile attribute and the <appSettings> keys to move the location of the configuration file.  I have Terminal Server users, so I’d really need to put the config somewhere user specific.  I think under %appData% would be best, but I can’t get the ConfigFile attribute or <appSettings> to work with that.

 

Is there a way to point the config to %appData%?  Is there a better way to change logging severity?

 

 

Thanks

Reply | Threaded
Open this post in threaded view
|

RE: Adjust log4net logging severity

Joe Joe-3

Not sure I fully understand all your requirements but:

 

-          If you want your users to be able to dynamically change the logging level while the application is running, then revert to the configured values when the application exits, you can use the techniques described here: http://stackoverflow.com/questions/738126/dynamically-reconfigure-log4net

 

-          If you want to be able to store a user-specific configuration file on disk, then (a) yes, somewhere application-specific under %appdata% would be reasonable (roaming application data); (b) in this case, call XmlConfigurator.Configure rather than using the ConfigFile attribute or <appSettings>.

 

From: Justin Taylor [mailto:[hidden email]]
Sent: 05 April 2016 22:19
To: [hidden email]
Subject: Adjust log4net logging severity

 

I’m working on a .NET Windows app, and I need the ability for the user to change the logging severity from within the app.  Right now, I have the logging severity set in my .config file, but that lives under Program Files so the user can’t modify that file.    I looked at the ConfigFile attribute and the <appSettings> keys to move the location of the configuration file.  I have Terminal Server users, so I’d really need to put the config somewhere user specific.  I think under %appData% would be best, but I can’t get the ConfigFile attribute or <appSettings> to work with that.

 

Is there a way to point the config to %appData%?  Is there a better way to change logging severity?

 

 

Thanks

Reply | Threaded
Open this post in threaded view
|

RE: Adjust log4net logging severity

Justin Taylor

Door #2.  I’ll check out XmlConfigurator.Configure.

 

 

Thanks

 

From: Joe [mailto:[hidden email]]
Sent: Tuesday, April 05, 2016 3:48 PM
To: Log4NET User <[hidden email]>
Subject: RE: Adjust log4net logging severity

 

Not sure I fully understand all your requirements but:

 

-          If you want your users to be able to dynamically change the logging level while the application is running, then revert to the configured values when the application exits, you can use the techniques described here: http://stackoverflow.com/questions/738126/dynamically-reconfigure-log4net

 

-          If you want to be able to store a user-specific configuration file on disk, then (a) yes, somewhere application-specific under %appdata% would be reasonable (roaming application data); (b) in this case, call XmlConfigurator.Configure rather than using the ConfigFile attribute or <appSettings>.

 

From: Justin Taylor [[hidden email]]
Sent: 05 April 2016 22:19
To: [hidden email]
Subject: Adjust log4net logging severity

 

I’m working on a .NET Windows app, and I need the ability for the user to change the logging severity from within the app.  Right now, I have the logging severity set in my .config file, but that lives under Program Files so the user can’t modify that file.    I looked at the ConfigFile attribute and the <appSettings> keys to move the location of the configuration file.  I have Terminal Server users, so I’d really need to put the config somewhere user specific.  I think under %appData% would be best, but I can’t get the ConfigFile attribute or <appSettings> to work with that.

 

Is there a way to point the config to %appData%?  Is there a better way to change logging severity?

 

 

Thanks