NLog xsi: type doesn't work with custom target

I wanted to write a custom target in NLog using this: https://github.com/nlog/nlog/wiki/How%20to%20write%20a%20Target

and write my logs to MongoDB, so my code looks like this:

namespace NLog.Mongo
{
    [Target("Mongo")]
    public sealed class MongoDBNLogTarget : Target
    {
        ...
        protected override void Write(NLog.LogEventInfo logEvent)
        {
            Repository.Insert(logEvent);
        }
    }
}

      

and I suppose my NLog.config file should look like this:

<?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">
  <extensions>
    <add assembly="NLog.Mongo"/>
  </extensions>
  <targets>
    <target name="mongo" xsi:type="Mongo"/>
  </targets>

  <rules>
    <logger name="*" minLevel="Info" writeTo="mongo" />
  </rules>
</nlog>

      

However, I am getting a warning:

This is an invalid xsi:type 'http://www.nlog-project.org/schemas/NLog.xsd:Mongo'

      

+3


source to share


1 answer


This is an XSD error and should be considered a warning. The XSD is generated with all possible targets (in the main NLog package) and therefore has no custom targets.



These errors can be ignored, and NLog will not stop working if the XML configuration contains these "errors".

+3


source







All Articles