Beispiel #1
0
		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);
		}
Beispiel #2
0
		public NLogLogger(Logger logger, NLogFactory factory)
		{
			Logger = logger;
			Factory = factory;
		}
Beispiel #3
0
 /// <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;
 }
Beispiel #4
0
		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;
 }