ObjectLogger 1.1.0
dotnet add package ObjectLogger --version 1.1.0
NuGet\Install-Package ObjectLogger -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObjectLogger" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ObjectLogger" Version="1.1.0" />
<PackageReference Include="ObjectLogger" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ObjectLogger --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ObjectLogger, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ObjectLogger@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ObjectLogger&version=1.1.0
#tool nuget:?package=ObjectLogger&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ObjectLogger
A custom logger for formatted logging
Installation
Install-Package ObjectLogger
Usage example
- Call
builder.Services.AddLogMessageLogger()
extension method to include the LogMessageLogger to the DI. This is the simplest logger with the included base class for logging.- Call
builder.Services.AddLogMessageLogger(builder.Configuration)
to set yourTupleConflictStrategy
settings (see more later).
- Call
- Change
ILogger
withILogMessageLogger
in every place you use the logger - Enjoy 😃
Tips
- You can inherit from LogMessage to use any custom class with this logger
- When using the Tuple feature, you might write the same key twice, to handle this I use
TupleConflictStrategy
:- "MAKE_LIST" - Default. Will convert the value to be a list of all values with the same key.
- "KEEP_FIRST" - Will keep only the first key-value
- "KEEP_LAST" - Will keep only the last key-value
- If you want to use your own class, use
IObjectLogger<T, O>
whereT
is the class name andO
is your custom log object - For better logging parsing and usage, change the logger format to only include the message itself
Contributing
- Fork it (https://github.com/javitolin/ObjectLogger/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Meta
Distributed under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Configuration (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Options (>= 9.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.2)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.