我在我的Asp.net核心應用程序使用NLOG到文件,但NLOG不能在文件中寫,我有文件都準備好了變更許可,但仍面臨proble。第一次創建文件,但無法寫入該文件中的日誌。NLOG不寫在Asp.net核心
這是我下面nlog.config文件代碼:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="C:\git\damienbod\AspNetCoreNlog\Logs\internal-nlog.txt">
<targets>
<target xsi:type="File" name="allfile" fileName="D:\nlog-all.txt"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}"
keepFileOpen="false"/>
<target xsi:type="EventLog"
name="String"
layout="Layout"
machineName="String"
source="Layout"
category="Layout"
eventId="Layout"
log="String"
maxMessageLength="Integer" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="*Info*" maxLevel="*Deubg*" writeTo="allfile" />
</rules>
</nlog>
這裏是我的控制器代碼
NLog.Logger _Logger= LogManager.GetCurrentClassLogger();
_Logger.Info("Hello i m executing");
我根據您的建議進行了修改@ FORCE JB,minlevel =「調試」但仍面臨同樣的問題 –
internalLogFile中是否有任何錯誤消息?似乎沒有其他不正確的設置,我有一個可行的NLog.config [github](https://github.com/KarateJB/Angular2.Mvc/blob/master/Angular2.Mvc/src/Angular2.Mvc.Website/NLog。配置),希望它有幫助! –