Using DateTimeOffset for LogEntry.TimeStamp?

Topics: Logging Application Block
Dec 30, 2010 at 3:06 AM


We are looking to move to EntLib5 for a new project while I was browsing the code I noticed that the LogEntry class still uses a regular DateTime for the TimeStamp property. Since EntLib requires .net 3.5SP1 as a minimum would there be any downside to changing it to use a DateTimeOffset to capture local timezone offset information as well? For any Listeners that cannot handle/store a DateTimeOffset the regular DateTime object in UTC is easy to pull from the DateTimeOffset.

Am I missing any reason this would be a bad idea?

Dec 30, 2010 at 5:42 AM

I couldn't think of any reason why this would be a bad idea either :-). The only concerns is that as you also mentioned TimeStamp property accepts DateTime type and not DateTimeOffset. What I can suggest is to add it in your LogEntry object's ExtendedProperties collection property.

            LogEntry log = new LogEntry();
            log.ExtendedProperties.Add("MyDateTimeOffset", DateTimeOffset.Now.ToString())

And make sure the token either "{dictionary({key} - {value}{newline})}" or {keyValue(MyDateTimeOffset)}. HTH

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.

Dec 30, 2010 at 5:51 AM

That is kind of my point, why not change LogEntry to actually use DateTimeOffset instead of DateTime. Not adding it as a borderline redundant extended property.



Dec 30, 2010 at 8:19 AM

I'm afraid I'm not qualified to answer you questions and don't know what's the rationale behind this. The entlib team should be able to provide more details regarding this. Anyway, for any feature request for entlib you can always log this type of items in the Issue Tracker section.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.