https://github.com/open-net-libraries/open.logging
Utilities and extensions for simplifying .NET logging.
https://github.com/open-net-libraries/open.logging
Last synced: 3 months ago
JSON representation
Utilities and extensions for simplifying .NET logging.
- Host: GitHub
- URL: https://github.com/open-net-libraries/open.logging
- Owner: Open-NET-Libraries
- License: mit
- Created: 2025-05-21T04:09:18.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-05-28T21:49:40.000Z (8 months ago)
- Last Synced: 2025-05-28T22:38:24.658Z (8 months ago)
- Language: C#
- Size: 378 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Open.Logging
A lightweight set of .NET libraries that enhances the standard logging infrastructure with additional formatters and extensions.
[](https://www.nuget.org/packages/Open.Logging.Extensions/)
## Features
- Seamless integration with Microsoft.Extensions.Logging
- Beautiful console output through Spectre Console integration
- Customizable log formatting and styling
- Support for log scopes and context
- Thread-safe logging operations
- Exception formatting and display
## Installation
```sh
dotnet add package Open.Logging.Extensions
```
or for more colorful output:
```sh
dotnet add package Open.Logging.Extensions.SpectreConsole
```
## Usage
### Basic Setup
```csharp
using Microsoft.Extensions.Logging;
using Open.Logging.Extensions.SpectreConsole;
// Add to your service collection
services.AddLogging(builder =>
{
builder.AddSimpleSpectreConsole();
});
// Inject and use
public class MyService
{
private readonly ILogger _logger;
public MyService(ILogger logger)
{
_logger = logger;
}
public void DoSomething()
{
_logger.LogInformation("Operation started");
// ...
}
}
```
### Customizing Log Level Labels
```csharp
var customLabels = new LogLevelLabels
{
Information = "INFO",
Warning = "ATTENTION",
Error = "PROBLEM"
};
services.AddLogging(builder =>
{
builder.AddSimpleSpectreConsole(options =>
{
options.Labels = customLabels;
});
});
```
### Custom Theming
```csharp
var theme = new SpectreConsoleLogTheme
{
// Configure colors and styles
};
services.AddLogging(builder =>
{
builder.AddSpectreConsole(options =>
{
options.Theme = theme;
});
});
```
## Requirements
These may expand in the future. If anyone needs legacy support, please fill out an request in the repo on GitHub.
- .NET 9.0
- C# 13.0
## License
MIT License - see the LICENSE file for details.