1
少しスパイクをしようとしていますが、ログファイルが生成されません。NLogがコンソールアプリケーションのapp.config設定を読み取っていません
これは私NLog構成である:ここ
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.2.4.0" newVersion="3.2.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<nlog throwExceptions="true"
internalLogLevel="Warning"
internalLogFile="Rebus.Tests.Output.NLog.Internal.log"
internalLogToConsole="true"
xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="normalLogfile" type="File" fileName="${basedir}/Rebus.Tests.Output.log" />
<target name="normalConsole" type="Console" detectConsoleAvailable="true" />
</targets>
<rules>
<logger name="NormalLog" minlevel="Trace" writeTo="normalLogfile, normalConsole" />
</rules>
</nlog>
</configuration>
、コンソールアプリケーションでの私の静的メインです:
var logger = LogManager.GetLogger("NormalLog");
logger.Error("This is a log error line");
しかし、何がLOGFILEもコンソールに記録されません。
application.exe.config
はbin/Debugランタイムフォルダにあります。 そして、私はSearchEverythingでログファイルを探していますので、それはどこのフォルダにもあります。私は何も設定が読み込まれなかった見ることができますlogger
変数を検査するために、ブレークポイントを置く場合は、この質問にはいくつかの情報を追加する
:
同じ動作:ロガーは空です。 とにかく、私は 'GetLogger'メソッドの' named logger'文字列はconfig.fileのルール名だと思います。 – ferpega
NLogドキュメントによると、 'GetLogger'メソッドを使用するときには、Loggerの名前を使用する必要があります。 app.configのnlog属性を取り戻そうとしましたか?それらのどれも問題ではないことを確かめてください。 –
それは問題だった@mightybdaboom Nlogの属性。それらの一部はサポートされていない必要があり、すべてのNLog設定を無効にしています。 それを記入するための答えとしてそれを入れてください。おかげさまで – ferpega