コード例 #1
0
		/// <summary>
		/// Create an appender to use for the logger
		/// </summary>
		/// <param name="handler">The error handler to use.</param>
		/// <returns></returns>
		private SmtpPickupDirAppender CreateSmtpPickupDirAppender(IErrorHandler handler)
		{
			SmtpPickupDirAppender appender = new SmtpPickupDirAppender();
			appender.PickupDir = _testPickupDir;
			appender.ErrorHandler = handler;
			return appender;
		}
コード例 #2
0
		/// <summary>
		/// Creates a logger hierarchy, configures a SMTP pickup dir appender and returns an ILogger
		/// </summary>
		/// <param name="appender">The appender to use</param>
		/// <returns>A configured ILogger</returns>
		private ILogger CreateLogger(SmtpPickupDirAppender appender)
		{
			Repository.Hierarchy.Hierarchy h = (Repository.Hierarchy.Hierarchy)LogManager.CreateRepository("TestRepository");

			PatternLayout layout = new PatternLayout();
			layout.ConversionPattern = "%m%n";
			layout.ActivateOptions();

			appender.Layout = layout;
			appender.ActivateOptions();

			h.Root.AddAppender(appender);
			h.Configured = true;

			ILogger log = h.GetLogger("Logger");
			return log;
		}