1

MVC Web Api アプリケーションで NLog を使用しています。NuGet パッケージ マネージャーを使用して NLog をインストールし、作成された Nlog.conf ファイルでログ ターゲットを構成しました。

 <targets>
   <target xsi:type="EventLog"
           name="eventlog"
           source="ImageService"
           machineName="."
           log="Application"
           layout="${longdate}|${level}|${message}"/>
 </targets>
<rules>
   <logger name="*" minlevel="Debug" writeTo="eventlog" />
 </rules>

次に、powershell を使用して新しいイベントを登録しました。

New-EventLog -Logname Application -Source ImageService

今C#コードで私は次のことをやっています

Logger _log = LogManager.GetCurrentClassLogger();
_log.Info("Demo message);

しかし、イベント ビューアー -> Windows ログ -> アプリケーションに移動し、ソース名 ImageService に基づいてフィルター処理すると、そこにエントリが表示されません。

上記のロガー コードは別のクラス ライブラリに記述されており、Web アプリケーションで参照され、ログ関数が呼び出されます。

ターゲットとルールの構成に問題はありますか?

4

0 に答える 0