Logging time stamp ERROR

Topics: Logging Application Block
Jun 3, 2008 at 9:32 AM
Hi, everybody!
I am using Ent Lib4 logging blocki   n my application, but the time stamp of trace message is not right. any body knows the reason?
PS: How  can i set the trace message time stamp rightly? 

thanks a lot!
Jun 12, 2008 at 9:12 PM
Hi,
You have to set time-stamp using LogEntry object.
Here is the snippet. Also keep in mind that LogEntry object expects time in UTC format.

messageLog =

new LogEntry();

 

 

messageLog.TimeStamp = DateTime.UtcNow;

 

 

messageLog.Severity = TraceEventType.Information;

 

 

messageLog.Message = "Message you want to Log";

//Now call Logger class to log message.

 

 

Logger.Write(this.messageLog);

You can also set additional properties like Category etc using LogEntry class.
Good Luck ! :-)


renam wrote:
Hi, everybody!
I am using Ent Lib4 logging blocki   n my application, but the time stamp of trace message is not right. any body knows the reason?
PS: How  can i set the trace message time stamp rightly? 

thanks a lot!


Jun 13, 2008 at 1:53 AM
If you observe daylight savings, storing your log messages in UTC is recommended. It prevents confusion when the clocks move backwards.  You will have older messages that have an eariler timestamp.  However, if I recall correctly, there was a change with EntLib 4 that allowed you to change it.

shadab1 wrote:
Hi,
You have to set time-stamp using LogEntry object.
Here is the snippet. Also keep in mind that LogEntry object expects time in UTC format.

messageLog =

new LogEntry();

 

 

 

messageLog.TimeStamp = DateTime.UtcNow;

 

 

 

messageLog.Severity = TraceEventType.Information;

 

 

 

messageLog.Message = "Message you want to Log";

//Now call Logger class to log message.

 

 

 

Logger.Write(this.messageLog);

You can also set additional properties like Category etc using LogEntry class.
Good Luck ! :-)


renam wrote:
Hi, everybody!
I am using Ent Lib4 logging blocki   n my application, but the time stamp of trace message is not right. any body knows the reason?
PS: How  can i set the trace message time stamp rightly? 

thanks a lot!





Jun 13, 2008 at 4:38 PM

There are text formatter tokens that can be used to indicate that a local timestamp should be used instead of the default UTC one. 

The timestamp token supports a local: prefix that indicates that the timestamp should be displayed in local time. Some examples of local timestamp format codes include {timestamp(local)}, which uses the default format string and {timestamp(local:F)}, which uses the F format string that represents the "full date/time" pattern. For more information about date/time formatting, see Standard DateTime Format Strings on MSDN.

Fernando

 


pbolduc wrote:
If you observe daylight savings, storing your log messages in UTC is recommended. It prevents confusion when the clocks move backwards.  You will have older messages that have an eariler timestamp.  However, if I recall correctly, there was a change with EntLib 4 that allowed you to change it.

shadab1 wrote:
Hi,
You have to set time-stamp using LogEntry object.
Here is the snippet. Also keep in mind that LogEntry object expects time in UTC format.

messageLog =

new LogEntry();

 

 

 

messageLog.TimeStamp = DateTime.UtcNow;

 

 

 

messageLog.Severity = TraceEventType.Information;

 

 

 

messageLog.Message = "Message you want to Log";

//Now call Logger class to log message.

 

 

 

Logger.Write(this.messageLog);

You can also set additional properties like Category etc using LogEntry class.
Good Luck ! :-)


renam wrote:
Hi, everybody!
I am using Ent Lib4 logging blocki   n my application, but the time stamp of trace message is not right. any body knows the reason?
PS: How  can i set the trace message time stamp rightly? 

thanks a lot!








Jul 9, 2008 at 2:03 PM

Thanks fsimonazzi!

The trick with the format string was very, very helpful.

Regards, Gerald