It looks like the EventContextLayoutRenderer uses Convert.ToString
which will lose the precision you are looking for:
public class EventContextLayoutRenderer : LayoutRenderer
{
//....
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
object value;
if (logEvent.Properties.TryGetValue(this.Item, out value))
{
builder.Append(Convert.ToString(value, CultureInfo.InvariantCulture));
}
}
}
As you probably know (and I'm not sure if it's helpful in your situation), but there is a Date layout where you can specify the format and/or a LongDate one which will provide something like 2014-01-01 12:12:12.1234
EDIT
For what it's worth, you can add a customer layout renderer very easily
[LayoutRenderer("event-context-dateTime")]
public class DateTimeContextLayoutRenderer : EventContextLayoutRenderer
{
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
object value;
if (logEvent.Properties.TryGetValue(this.Item, out value))
{
//Your code here
}
}
}
And in your configuration
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="YourAssembly"/>
</extensions>
<targets>
<target xsi:type="File" name="file" fileName="c:\temp\NlogLayout.txt"
layout="${longdate} ${event-context-dateTime:item=RequestDate}" />
...
</nlog>