Re: Put log in IIS virtual path (map ~/logpath)?
I ended up making my own LayoutRenderer and it seems to work so far.
using System;
using System.Text;
using System.Web;
using NLog;
namespace NLogUtils
{
[LayoutRenderer("virtualpath")]
public sealed class ScratchDirRenderer: LayoutRenderer
{
private string _vPath = String.Empty;
// this is an example of a configurable parameter
public string VPath
{
get { return _vPath; }
set { _vPath = value; }
}
protected override int GetEstimatedBufferSize(LogEventInfo ev)
{
// roughly max path size of 255
return 255;
}
protected override void Append(StringBuilder builder, LogEventInfo ev)
{
builder.Append(ApplyPadding(HttpContext.Current.Server.MapPath(VPath)));
}
}
}
<target name="file" xsi:type="File" fileName="${virtualpath:vPath=~/logpath/}${shortdate}.txt"/>
|