Search code examples
postsharp

why postsharp log level can only be changed once


we are using the following codes in app_start to change log level dynamically by retrieving the log level from web.config.

LoggingServices.GetSource(LoggingRoles.Tracing).SetLevel(LogLevel.Debug)); 

after build, we change the log level to Error, we don't see debug level information anymore, but if we change it back to Debug, we still don't see the debug level information. If we set initial level to be Error, after rebuild, we don't any debug info, then change level to Debug, we see debug information, then we change it to Error, we still see debug information. the change of log level only work once.


Solution

  • The only cause I can see is that you have the AllowDynamicEnabling property set to false in your logging profile. See http://doc.postsharp.net/log-enabling#optimizing.

    In other cases, you should be able to change the verbosity dynamically. We fixed a bug related to this a couple of months ago, so make sure you have a recent version.