コード例 #1
0
ファイル: NLogTests.cs プロジェクト: leloulight/Core
		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);
		}
コード例 #2
0
ファイル: NLogLogger.cs プロジェクト: nats/castle-1.0.3-mono
		public NLogLogger(Logger logger, NLogFactory factory)
		{
			Logger = logger;
			Factory = factory;
		}
コード例 #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;
 }
コード例 #4
0
ファイル: NLogTests.cs プロジェクト: leloulight/Core
		private void WriteLogMessage(NLogFactory factory)
		{
			var logger = factory.Create("MyLoggerName");
			logger.Debug("something");
		}
コード例 #5
0
 public NLogLogger(Logger logger, NLogFactory factory, MappedDiagnosticsLogicalContextDelegate mappedDiagnosticsLogicalContextDelegate)
     : this(logger, factory)
 {
     this.mappedDiagnosticsLogicalContextDelegate = mappedDiagnosticsLogicalContextDelegate;
 }