ExtremelySimpleLogger/Sample/Program.cs

31 lines
946 B
C#
Raw Normal View History

2020-07-23 02:24:18 +02:00
using System;
using System.IO;
using ExtremelySimpleLogger;
namespace Sample {
internal static class Program {
2020-07-23 02:46:34 +02:00
private static void Main() {
2020-07-23 02:24:18 +02:00
var logger = new Logger {
Name = "Test Logger",
Sinks = {
2020-07-23 02:46:34 +02:00
new FileSink("Log.txt", true) {MinimumLevel = LogLevel.Trace},
2020-07-23 02:24:18 +02:00
new ConsoleSink()
}
};
logger.Info("Logger loaded.");
logger.Info("Program starting.");
logger.Warn("Unsafe code follows!");
try {
File.OpenRead("does/not/exist");
} catch (Exception e) {
logger.Error("An exception was thrown!", e);
}
2020-07-23 02:46:34 +02:00
logger.Log(LogLevel.Trace, "This is a message that only the file sink will receive, since its minimum level is lower.");
logger.Log(LogLevel.Info, "The program finished.");
2020-07-23 02:24:18 +02:00
}
}
}