Headers (and footers) only used by targets derevived from TargetWithLayoutHeaderAndFooter
Because the MemoryTarget
is deriving from the TargetWithLayout
and not from the TargetWithLayoutHeaderAndFooter
setting the WithHeader = true
does not have any effect on the the MemoryTarget
. So you cannot get the header in MemoryTarget.Logs
.
In order to the header outputted correctly you need to use one of targets which supports it:
- Console
- Colored Console
- File
- Debugger
Or you can directly access the generated header in your code with the help of LogEventInfo.CreateNullEvent()
and calling:
string header = ((CsvLayout)MemoryTarget.Layout).Header
.Render(LogEventInfo.CreateNullEvent());