In my application, I work on several thousand of document a day. I\'d like, in some cases some logs, one log by document. Then I\'d like for a specific target change the out
This worked for me.
using NLog;
using NLog.Targets;
using NLog.Targets.Wrappers;
var target = LogManager.Configuration.FindTargetByName("logfile");
var asyncTarget = target as AsyncTargetWrapper;
var fileTarget = asyncTarget.WrappedTarget as FileTarget;
var file = fileTarget.FileName;
var archiveFile = fileTarget.ArchiveFileName;
//FileName and ArchiveFileName are of type Layout. ToString gives the string representaion. We can change it and assign it back. Remember to put .Trim('\'') for removing the extra single quotes that gets added while converting to string.