在我的.NET Core应用程序中,我使用了一些环境,并且我想为不同的路径来记录每个环境的文件。更改日志文件的动态文件路径.NET Core + NLog
例如,
Development - c:\logs
Staging - d\apps\logs
对于每一个环境我有配置部分中appsettings.{env}.json
:
"LocalPaths": {
"LogFileRootDirectory": "c:\\logs\\"
}
和部分nlog.config
:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="${logFileRootDirectory}internal-nlog.txt">
...
</nlog>
什么来实现的最佳途径?
我在哪里可以配置'LogManager'?进入'Startup.cs'?因为如果我将其设置为'Startup.cs''配置'方法,我有一个错误'对象引用未设置为对象的实例。''loggerFactory.AddNLog();'后面的 –
,请参阅https:// github。 com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-(project.json) – Julian
它的工作机会? – Julian