【发布时间】:2019-09-05 16:14:36
【问题描述】:
我有运行在 Ubuntu 16.04 上的 asp.net core 1.1 应用程序。使用 NLog 配置日志记录:
loggerFactory.AddNLog();
loggerFactory.ConfigureNLog("nlog.config");
app.AddNLogWeb();
在我的开发 Windows 系统上,一切正常:已创建日志文件夹,并且日志记录按预期工作。但在 Linux 日志记录不起作用。怎么了?
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="internal-nlog.txt">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<variable name="logDirectory" value="logs/${shortdate}" />
<variable name="logRootDirectory" value="logs" />
<targets>
<target name="fileLogTrace" xsi:type="File" fileName="${logDirectory}/trace.txt" />
<target name="fileLogDebug" xsi:type="File" fileName="${logDirectory}/debug.txt" />
<target name="fileLogInfo" xsi:type="File" fileName="${logDirectory}/info.txt" />
<target name="fileLogWarn" xsi:type="File" fileName="${logDirectory}/warn.txt" />
</targets>
<rules>
<logger name="*" level="Trace" writeTo="fileLogTrace" />
<logger name="*" level="Debug" writeTo="fileLogDebug" />
<logger name="*" level="Info" writeTo="fileLogInfo" />
<logger name="*" level="Warn" writeTo="fileLogWarn" />
</rules>
</nlog>
【问题讨论】:
-
什么版本的 NLog?您是否有权在文件夹中写入文件?你检查过 internal-nlog.txt 吗?
-
@RolfKristensen NLog 5.0 beta 是的所有权限我什至在 Windows 上都找不到这个文件。应该放在哪里?在应用根文件夹中?
标签: c# linux asp.net-core nlog