Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTimeOffset in Log4Net

What is log4net.Layout.PatternLayout value to output DateTimeOffset data type to database?

This is what I have currently in configuration file for log4net:

<log4net>
....
<parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
</parameter>
...
</log4net>

And I want to have something like:

<log4net>
....
<parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTimeOffset" />
      <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff **OFFSET**}" />
</parameter>
...
</log4net>

Basically we reuse the same DB to log events from clients located in different time zones - so we want to know an exact local time of the event.

Thanks, Alex

like image 282
user2216889 Avatar asked Mar 27 '13 18:03

user2216889


1 Answers

You should be able to use any valid DateTime format string. Try this:

%date{yyyy-MM-ddTHH:mm:ss.fffzzz}
like image 168
Matt Johnson-Pint Avatar answered Oct 18 '22 19:10

Matt Johnson-Pint