A very simple logger for .NET programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ellpeck 5072fde64b
Create FUNDING.yml
3 weeks ago
.github Create FUNDING.yml 3 weeks ago
ExtremelySimpleLogger update 3 weeks ago
Sample made the default minimum level trace for everything 1 year ago
.gitignore Initial commit 1 year ago
ExtremelySimpleLogger.sln basic implementation 1 year ago
Jenkinsfile reflect branch name change 1 month ago
LICENSE Create LICENSE 1 year ago
Logo.png decrease the logo's size 3 weeks ago
README.md added readme and logo to package 3 weeks ago

README.md

The ExtremelySimpleLogger logo

ExtremelySimpleLogger is a very simple logger for .NET programs.

To set up an extremely simple logger, add a reference to the NuGet package to your project file. Remember to change the VERSION to the most recent one.

<ItemGroup>
    <PackageReference Include="ExtremelySimpleLogger" Version="VERSION" />
</ItemGroup>

Next, you have to create an instance of the Logger class:

var logger = new Logger {
    Name = "My Logger",
    Sinks = {
        new FileSink("Log.txt", append: true),
        new ConsoleSink()
    }
};

Since there are multiple ways for logging data to be processed, the logger needs to receive a set of Sink instances. By default, the following sinks are available:

  • FileSink, which outputs logging data to a file
  • ConsoleSink, which outputs logging data to the default console
  • DirectorySink, which outputs logging data to a set of files and automatically manages how many old logs are kept
  • StringSink, which stores logging data in a string

There are multiple ways to easily log messages with your newly created logger:

// Logging info
logger.Log(LogLevel.Info, "Some information");
logger.Info("Some information, but shorter");

// Logging exceptions
try {
    // some dangerous code
} catch (Exception e) {
    logger.Error("An exception was thrown", e);
}

For more information, you can also check out the sample.