간단한 ASP.NET 웹 사이트를 만들고 NLog를 추가했지만 로그 파일을 만들지 않고 예외도 throw하지 않습니다. 문제 해결을 시도했지만 https://github.com/NLog/NLog/wiki/Logging-troubleshooting에 도움이되지 않습니다.
내 web.config
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="true"
internalLogLevel="Off"
internalLogFile="c:\temp\nlog-internal.log">
<targets>
<target name="file" type="File" fileName="C:\log.txt" />
</targets>
<rules>
<logger name="File" minlevel="Trace" writeTo="file" />
<logger name="FileNotFound" minlevel="Trace" writeTo="file-404" />
</rules>
</nlog>
그런 다음 아래 페이지를 실행했는데 아무 일도 일어나지 않습니다 ...
public partial class Test1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LogManager.ThrowExceptions = true;
Logger logger = LogManager.GetLogger("foo");
Logger log = LogManager.GetCurrentClassLogger();
log.Error("some test");
logger.Error("some test 2");
}
}
내 잘못이 뭐야? 감사합니다!
의 name
속성은 <logger>
필터 (이름)입니다.
이제 "File"및 "FileNotFound"라는 이름으로 로거에서 필터링합니다.
이것은 파일에 모두 씁니다
<logger name="*" minlevel="Trace" writeTo="file" />
또 다른 옵션은 C #에서 명명 된 로거를 사용하는 것이므로
Logger log = LogManager.GetCurrentClassLogger();
사용하다
Logger log = LogManager.GetLogger("FileNotFound");
그런 다음 <logger name="FileNotFound" ..>
구성에서 사용할 수 있습니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다