public void Should_preserve_correct_callsite_information() { // Step 1. Create configuration object var config = new LoggingConfiguration(); // Step 2. Create targets and add them to the configuration var target = new MemoryTarget(); config.AddTarget("target", target); // Step 3. Set target properties target.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${callsite} ${message}"; // Step 4. Define rules var rule = new LoggingRule("*", LogLevel.Debug, target); config.LoggingRules.Add(rule); var factory = new NLogFactory(config); WriteLogMessage(factory); var logMessage = target.Logs[0]; StringAssert.Contains("NLogTests.WriteLogMessage", logMessage); }
public NLogLogger(Logger logger, NLogFactory factory) { Logger = logger; Factory = factory; }
/// <summary> /// Initializes a new instance of the <see cref="NLogLogger" /> class. /// </summary> /// <param name="logger"> The logger. </param> /// <param name="factory"> The factory. </param> public NLogLogger(Logger logger, NLogFactory factory) { Logger = logger; Factory = factory; }
private void WriteLogMessage(NLogFactory factory) { var logger = factory.Create("MyLoggerName"); logger.Debug("something"); }
public NLogLogger(Logger logger, NLogFactory factory, MappedDiagnosticsLogicalContextDelegate mappedDiagnosticsLogicalContextDelegate) : this(logger, factory) { this.mappedDiagnosticsLogicalContextDelegate = mappedDiagnosticsLogicalContextDelegate; }