public void IndexLogsEvents() { // Initialise the configuration var config = new LoggingConfiguration(); var target = new MemoryTarget { Layout = "${Logger}|${Level}|${Message}" }; config.AddTarget("unitTesting", target); var rule = new LoggingRule("*", LogLevel.Debug, target); config.LoggingRules.Add(rule); // Generate the logger var factory = new LogFactory { Configuration = config }; var logger = factory.GetLogger(typeof(DynamicController).FullName); try { DynamicController.OverrideLogger(logger); var controller = new DynamicController(); // Resolve an action that doesn't exist - we are only interested that logging is actually workig controller.Index("blankServerName", "blankProjectName", "blankBuildName", "nowherenonsenseaction"); var expectedMessages = new[] { MakeMessage("Dynamically resolving request", LogLevel.Debug), MakeMessage("Generating request context", LogLevel.Debug), MakeMessage("Action is a build level report", LogLevel.Debug), MakeMessage("Retrieving action handler for nowherenonsenseaction", LogLevel.Debug), MakeMessage("Unable to find action handler for nowherenonsenseaction", LogLevel.Info), MakeMessage("Generating error message", LogLevel.Debug) }; Assert.That(target.Logs.ToArray(), Is.EqualTo(expectedMessages)); } finally { DynamicController.ResetLogger(); } }