다음의 Web.config에서 값을 가져옵니다 ${aspnet-config:SmtpHostServer}
:
이상적으로 내가 좋아하는 일을하고 싶습니다). 당신이 당신의 자신의 어셈블리에 넣어이라면 NLog.Config에 다음을 추가하는 것을 잊지 마세요 :
[LayoutRenderer("aspnet-config")]
public class AspNetConfigValueLayoutRenderer : LayoutRenderer
{
[DefaultParameter]
public string Variable
{
get;
set;
}
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
if (this.Variable == null)
{
return;
}
HttpContext context = HttpContext.Current;
if (context == null)
{
return;
}
builder.Append(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings[this.Variable], CultureInfo.InvariantCulture));
}
}
@Julian을 공유해 주셔서 감사합니다. - 유용합니다. 이후 로깅 공급자를 변경했습니다. – DaveHogan