Essentially I have developed a C# Service that runs and uses the Enterprise Library Library 5.0 Logging that is configured by the App.config in my project. I made a custom text formatter in App.config for my service that looks like the following:
{timestamp(local)} [{win32ThreadId}{dictionary(:{value})}] {message}
During my service's runtime, if I change the Time Zone, the system clock will automatically update to reflect that Time Zone change, however the time change is not picked up in the subsequent logg开发者_如何学JAVAing calls.
Conversely, if I change the actual system clock myself without changing the Time Zone, it does pickup the time change in the subsequent logging calls.
Does anyone know if this is a bug in Enterprise Library? I can't seem to find any related problems on here or google about it after exhaustive searching.
The behavior you are seeing isn't a bug in Enterprise Library, it's a behavior of .NET.
The time zone data is cached because it is assumed to be fairly static data.
Cached time zone data includes data on the local time zone, the Coordinated Universal Time (UTC) zone, and any time zones that are retrieved by using methods such as FindSystemTimeZoneById and GetSystemTimeZones.
If it's really an issue, you can clear the cache by calling TimeZoneInfo.ClearCachedData()
.
精彩评论