2

ロギング フレームワークとして NLog を使用し、外部変換構成ファイル (NLog.Debug.config など)に「最適」な設定を見つけようとします。

プロジェクトのwiki ページには、次の2 つのオプションがあります。

  1. インライン (例: Web.config または App.config 内)
  2. ルート要素<nlog>としての外部構成ファイルの単純化された xml

構成例を次に示します。

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true">
  <targets async="true">
    <target name="Warn" xdt:Transform="Remove" xdt:Locator="Match(name)" />
  </targets>
  <rules>
    <logger writeTo="Warn" xdt:Transform="Remove" xdt:Locator="Match(writeTo)" />
  </rules>
</nlog>

多くの名前空間にもかかわらず、Visual Studio 2015 は次の警告を表示します。 The 'nlog' element is not declared.

要素内に nlog 部分を配置すると<configuration>、この警告は消えますが、名前、ターゲット、非同期などの要素が不明であることを示す多くの「メッセージ」が表示されます。 Could not find schema information for the element 'target'.

名前空間定義 ( ) からサフィックスnlogを削除するとxmlns:nlog="...、ルート要素は受け入れられますが、target、xdt:Transform、xdt:Locator などの要素に関する警告が表示されます。

The element 'http://www.nlog-project.org/schemas/NLog.xsd:target' is abstract or its type is abstract.
The 'autoreload' attribute is not declared.
The 'name' attribute is not declared.
...

名前空間を別の要素に移動するか、すべての要素または属性に対応するプレフィックスを付けようとしましたが、すべての警告またはメッセージが消えるのを助けるものは何もありません...

編集:属性には、次のような警告が引き続きマークされます。 The 'http://schemas.microsoft.com/XML-Document-Transform:Locator' attribute is not declared.

4

1 に答える 1

0

最善の方法は、NLog.XSD をダウンロードして同じディレクトリに追加することです。

このファイルは NLog.Schema パッケージに含まれています ( Nuget へのリンク) 。

編集:これは私にとってはうまくいきます.NLogはそうではxmlnsありませんxmlns:nlog

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoreload="true">
于 2016-11-23T23:18:15.137 に答える