我在 centos 中将 Nlog 与 dotnet-core-2.2 一起使用,但出现日志文件路径设置问题
I using Nlog with dotnet-core-2.2 in centos but a problem with log file path setting is appear
我正在 运行 在 centos.I 上安装一个 aspnet 核心控制台程序,已设置 nlog.config 以生成日志文件。在我的 windows 开发环境中一切都很好,但是当我在 Centos 上 运行 它时,我无法使用我的设置获取日志文件。
我的设置:
<target xsi:type="File" name="target1" fileName="${currentdir}\logs${shortdate}-nlog.log" ... />
In centos:(click to show img)
它将在父目录中创建一个文件名 "demoBS\logs19-06-26-nlog.log"。
谢谢,期待您的帮助!
Ps: Nlog.config
<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="${currentdir}\logs${shortdate}-internal.log"
internalLogLevel="Info" >
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="target1" fileName="${currentdir}\logs${shortdate}-nlog.log"
layout="${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
<target xsi:type="Console" name="target2"
layout="${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="target2,target1" />
</rules>
</nlog>
确保使用 Unix-path 而不是 Windows-path。例如:
${currentdir}/logs/${shortdate}-nlog.log
将斜线反方向
我正在 运行 在 centos.I 上安装一个 aspnet 核心控制台程序,已设置 nlog.config 以生成日志文件。在我的 windows 开发环境中一切都很好,但是当我在 Centos 上 运行 它时,我无法使用我的设置获取日志文件。 我的设置:
<target xsi:type="File" name="target1" fileName="${currentdir}\logs${shortdate}-nlog.log" ... />
In centos:(click to show img) 它将在父目录中创建一个文件名 "demoBS\logs19-06-26-nlog.log"。
谢谢,期待您的帮助!
Ps: Nlog.config
<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="${currentdir}\logs${shortdate}-internal.log"
internalLogLevel="Info" >
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="target1" fileName="${currentdir}\logs${shortdate}-nlog.log"
layout="${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
<target xsi:type="Console" name="target2"
layout="${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="target2,target1" />
</rules>
</nlog>
确保使用 Unix-path 而不是 Windows-path。例如:
${currentdir}/logs/${shortdate}-nlog.log
将斜线反方向