The analogue of NLog analogue of log4net-applications will be the target. To create your own goal, you must inherit from NLog.Targets.TargetWithLayout . You should also mark your target class with the TargetAttribute attribute:
[Target("Foo")] public class FooTarget : TargetWithLayout { protected override void Write(LogEventInfo logEvent) { Console.WriteLine(logEvent.Message); } }
The next step is the assembly in which your class is defined for NLog extensions:
<nlog> <extensions> <add assembly="MyBarAssembly"/> </extensions> <targets> ...
And the last step is to register your target (NLog will look in the extensions for the TargetAttribute type TargetAttribute )
<target name="foo" type="Foo"/>
Sergey Berezovskiy
source share