NLog.LogManager.Configuration = loggingConfig;Here is an example:
{
var target = new NLog.Targets.MethodCallTarget();
target.ClassName = this.GetType().AssemblyQualifiedName;
target.MethodName = "OnErrorLogged";
target.Parameters.Add(new MethodCallParameter("${level}"));
target.Parameters.Add(new MethodCallParameter("${message}"));
var loggingConfig = NLog.LogManager.Configuration;
loggingConfig.AddTarget("UIErrorMonitor", target);
var loggingRule = new LoggingRule("*", NLog.LogLevel.Error, target);
loggingConfig.LoggingRules.Add(loggingRule);
NLog.LogManager.Configuration = loggingConfig;
}
public static void OnErrorLogged(string level, string message)
{
// do stuff}