Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EnterpriseLibrary.Logging writes logs with 1 hour difference

we encounter a weird problem with logging. We are using Microsoft.Practices.EnterpriseLibrary.Logging library for logging in our web application and the problem is that it writes the log with 1 hour difference from the current system time.

Our logger is based on this article and the time in a log entry is never set in code by us. Every log entry has a title which looks like this:

MainLogSource Information: 0 : Timestamp: 11/04/2011 10:15:32 so this timestamp always 1 hour earlier than system time (e.g. this entry appeared at 11:15).

Where can be the problem? Thanks

like image 869
Burjua Avatar asked Apr 11 '11 10:04

Burjua


2 Answers

By default Enterprise Library logs using UTC timestamp, so these are unaffected by daylight savings time.

You can change the formatter in the .config file to use local time (see attached question), but be aware that this will result in duplicate entries when daylight savings time changes occur.

Enterprise Library 5.0 - Application Logging - Incorrect DateTime

like image 115
DaveRead Avatar answered Nov 15 '22 16:11

DaveRead


Cultural ignorance of one side of the comparison?

As in: the logger writes out the time in UTC and you compare it to the local system time and just happen to have it set to a one hour difference? Central Europe, for example, is 1 hour ahead of UTC time (half of the year).

What are your locale settings? This is a quite common phenomenon. Basically to be comparable loggers etc. LOVE setting things in UTC, and you should do so, too. I know companies running the servers in UTC time locale wise so it is easier to compare logs to the system clock (at the price to the system clock always being off).

like image 45
TomTom Avatar answered Nov 15 '22 15:11

TomTom