Bug in date/time format

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in date/time format

Ihor Bobak
I've got the last release of NLog (10/26).

If I write <parameter name="@date" layout="${date:format=yyyy-MM-dd HH:mm:ss}" />, then it cuts  the format to "yyyy-MM-dd HH" since it thinks that ":" is the beginning of new property.

What can I do to set the format to yyyy-MM-dd HH:mm:ss ?
Reply | Threaded
Open this post in threaded view
|

Re: Bug in date/time format

Jarek Kowalski
Administrator
To use : you need to add a backslash before it. Like this:

HH\:mm\:ss

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Bug in date/time format

Steph
This doesn't work.  If I use ${date:format=yyyy-MM-dd - HH\:mm\:ss} in my archiveFileName it doesn't archive anything, it just stops writing to the file
Reply | Threaded
Open this post in threaded view
|

Re: Bug in date/time format

Jarek Kowalski
Administrator
That is because colon is not a valid character in file name. You should use something line ${date:format=yyyyMMdd-HHmmss} (without separators).
 
Jarek

On Thu, Apr 1, 2010 at 1:48 AM, Steph [via NLog Forum] <[hidden email]> wrote:
This doesn't work.  If I use ${date:format=yyyy-MM-dd - HH\:mm\:ss} in my archiveFileName it doesn't archive anything, it just stops writing to the file


View message @ http://n2.nabble.com/Bug-in-date-time-format-tp1685361p4835903.html
To start a new topic under NLog Forum, email [hidden email]
To unsubscribe from NLog Forum, click here.


NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Bug in date/time format

Valon Cross
This delimiter escaping is working with version 2.0 if you use a single back slash \:

<variable name="fmt" value="${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}]: ${message}"/>
  <targets>
    <target name="logfile" xsi:type="File" fileName="file.log" layout="${fmt}" />
  </targets>

is logging the current time like:  
2012-01-07 13:11:05 [Info]: ### Program Start ###

- Valon -