public void TestFileLogging() { using (var fileProvider = new FileProvider("./test.txt", true)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } var lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(2, lines.Length); Assert.IsTrue(lines[0].Contains("Info")); Assert.IsTrue(lines[1].Contains("Error")); TheLog.ClearProviders(); using (var fileProvider = new FileProvider("./test.txt", false)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(4, lines.Length); TheLog.ClearProviders(); using (var fileProvider = new FileProvider("./test.txt", true)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(2, lines.Length); TheLog.ClearProviders(); }