I wanted to write 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 imagine 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 get warning:
This is an invalid xsi:type 'http://www.nlog-project.org/schemas/NLog.xsd:Mongo'