Skip to content
Community contributions to NLog
Branch: master
Clone or download
Pull request Compare This branch is 26 commits behind NLog:master.

NLog Contrib

Community contributions to NLog.

##Adding a new target

It’s easy. Just put the target in a DLL and reference it from the the config file using the clause as described here.

Configuration file example:

    <add assembly="MyAssembly"/> 
    <target name="a1" type="MyFirst" host="localhost"/> 
    <logger name="*" minLevel="Info" appendTo="a1"/> 

You can also use TargetFactory.AddTarget() to register your target programmatically. Just be sure to do it at the very beginning of your program before any log messages are written. It should be possible to reference your EXE using the <extensions /> clause.

static void Main(string[] args) 
    ConfigurationItemFactory.Default.Targets.RegisterDefinition("MyFirst", typeof(MyNamespace.MyFirstTarget));
    // start logging here 
You can’t perform that action at this time.