问题
I am using Microsoft Enterprise library 5.0 for application logging of my .net application.
Logging is working properly. But the problem is the DateTime that is being logged along with the logging message is incorrect. There is a time difference of 6.5 hrs.
How can i correct this?
回答1:
Change your text formatter (in app.config) to use the local server time, otherwise it defaults to UTC.
e.g. change {timestamp} token to {timestamp(local)}
回答2:
Changing in the config file will just reflect in the extended properties, the "TimeStamp" field will still show the time in UTC format. To Change it at both place you can just update it in your code using the TimeStamp property of LogEntry. Refer here: EnterpriseLibrary.Logging writes logs with 1 hour difference
来源:https://stackoverflow.com/questions/4561303/enterprise-library-5-0-application-logging-incorrect-datetime