NLogに問題があります。 私は、次のようにファイルNlog.configにNLogを設定している:ASP.NET MVC - NLogファイルのターゲットが見つかりません
<?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"
throwExceptions="true"
internalLogLevel="Trace"
internalLogFile="d:\temp\nlog-internal.log">
<target xsi:type="File" name="log" fileName="${basedir}\logs\${date:format=dd}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
<rules>
<logger name="*" minlevel="Debug" writeTo="log" />
</rules>
</nlog>
そして、私はターゲットログがが見つからないというエラーが表示されます。私は本当に何ができるかわからない、誰かが似たような問題を抱えているかもしれない。
私は.NET 4.5を使用しています。
Nlog.configは、プロジェクトのメインディレクトリにあります。 ディレクトリ内のフルアクセス権を設定しました。
設定をweb.configファイルに移動しようとしましたが、エラーが引き続き表示されます。プロジェクトの
2016-07-26 09:17:25.6353 Warn Skipping unknown node: target
2016-07-26 09:17:25.6353 Trace ParseRulesElement
2016-07-26 09:17:25.6623 Error Error in Parsing Configuration File. Exception: NLog.NLogConfigurationException: Exception occurred when loading configuration from D:\Project\NLog.config ---> NLog.NLogConfigurationException: Target log not found.
w NLog.Config.XmlLoggingConfiguration.ParseLoggerElement(NLogXmlElement loggerElement, IList`1 rulesCollection)
w NLog.Config.XmlLoggingConfiguration.ParseRulesElement(NLogXmlElement rulesElement, IList`1 rulesCollection)
w NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String filePath, Boolean autoReloadDefault)
w NLog.Config.XmlLoggingConfiguration.ParseTopLevel(NLogXmlElement content, String filePath, Boolean autoReloadDefault)
w NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
構造:
更新(ミシェル・A.答えた後):私もNLog.configのプロパティを持っているファイル
Build Action = Content
Copy to Output Directory = Copy always
アップデート2 :解決策が見つかりました。問題は、私はバックスラッシュの代わりに、前方が
間違った構文スラッシュ持っているということでした。
fileName="${basedir}\logs\${date:format=dd}.log"
正しい構文:
fileName="${basedir}/logs/${date:format=dd}.log"
解決策フォルダ内の/ logs /フォルダを確認し、現在のユーザーに読み取り権限または書き込み権限があるかどうかを確認します(存在する場合)。あなたの現在の写真では、それは解決の一部ではないので、これは問題になる可能性があります。 – Marco
解決策が見つかりました。私は更新をしました。返信ありがとう:) –