2011-04-25 72 views
4

我創建了一個custom target for NLog,它工作正常,但是當我編輯nlog.config文件我得到一個警告,This is an invalid xsi:type 'http://www.nlog-project.org/schemas/NLog.xsd:LogMillMessageBus'NLOG定製目標XSD警告

這是我nlog.config文件:

<?xml version="1.0" ?> 
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 

    <extensions> 
     <add assembly="Core.v40.NLog.Extensions"/> 
    </extensions> 

    <targets async="true"> 
     <target name="LogMillMessageBus" xsi:type="LogMillMessageBus"/> 

     <target name="Console" xsi:type="ColoredConsole" layout="${date:format=HH\:mm\:ss.fff} ${message} ${exception:format=tostring}${event-context:item=Details}"/> 
    </targets> 

    <rules> 
     <logger name="*" minlevel="Trace" writeTo="Console" /> 
     <logger name="*" minlevel="Debug" writeTo="LogMillMessageBus" /> 
    </rules> 
</nlog> 

我可以以某種方式創建我自己的xsd,並追加http://nlog-project.org/schemas/NLog.xsd以便我不會收到警告嗎?

+0

你是否從visual studio得到這個警告? – 2013-06-13 15:13:41

+0

@BrandonAGr您的代碼鏈接被破壞,我有問題進行自定義,您可以請提供一些示例代碼。 – PUG 2014-11-07 17:36:09

+1

@jaminator https://github.com/NLog/NLog/wiki/How-to-write-a-target https://web.archive.org/web/20130129070949/http://nlog-project.org/維基/ How_to_write_a_Target – BrandonAGr 2014-11-09 03:29:06

回答

4

簡單的方法是安裝該軟件包https://nuget.org/packages/NLog.Schema/2.0.1.2

難的方法(我的第一種方法)是獲取失蹤XSD,並告訴Visual Studio中使用它。

您可以從此頁獲取xsd http://nlog.codeplex.com/releases/view/32639。我下載了版本NLog2.netfx40.zip,解壓縮並將NLog.netfx40.xsd複製到我的項目的根目錄中。要告訴Vusual Studio使用它,你應該打開菜單「XML-> Schemas ...」(如果你打開一個xml文件進行編輯,就會在TEAM和TOOLS之間出現XML菜單)並添加xsd文件。現在在我的情況下,最後一個問題是錯誤的xmlns。所以我在我的配置中將其從http://www.nlog-project.org/schemas/NLog.xsd更改爲http://www.nlog-project.org/schemas/NLog.netfx40.xsd