我創建了簡單的ASP.NET網站,添加了NLog,但它不會創建任何日誌文件,也不會引發任何異常。我試圖排除故障,但它並不能幫助https://github.com/NLog/NLog/wiki/Logging-troubleshootingNLog for ASP.NET網站不會記錄
我的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");
}
}
什麼是我的錯?謝謝!
我試圖<目標名稱= 「文件」 的xsi:type = 「文件」 文件名=「$ {BASEDIR}/App_Data文件/日誌/ WebSiteLog - $ {shortdate} .log「,但它也不起作用 – ihorko