![]() |
VOOZH | about |
dotnet add package stbychkov.AutoLoggerMessage --version 1.0.15
NuGet\Install-Package stbychkov.AutoLoggerMessage -Version 1.0.15
<PackageReference Include="stbychkov.AutoLoggerMessage" Version="1.0.15" />
<PackageVersion Include="stbychkov.AutoLoggerMessage" Version="1.0.15" />Directory.Packages.props
<PackageReference Include="stbychkov.AutoLoggerMessage" />Project file
paket add stbychkov.AutoLoggerMessage --version 1.0.15
#r "nuget: stbychkov.AutoLoggerMessage, 1.0.15"
#:package stbychkov.AutoLoggerMessage@1.0.15
#addin nuget:?package=stbychkov.AutoLoggerMessage&version=1.0.15Install as a Cake Addin
#tool nuget:?package=stbychkov.AutoLoggerMessage&version=1.0.15Install as a Cake Tool
π NuGet
π Build
π License
π NuGet Downloads
π PRs Welcome
Welcome to AutoLoggerMessage, a source generator that automatically creates LoggerMessage methods, enabling high-performance logging.
Click the image below to watch the demo video:
dotnet add package stbychkov.AutoLoggerMessage
Check this page for configuration options that can tweak the source generation process.
You can achieve performance boosts of up to 90% just by including this source generator in your project.
For ILogger.Log* methods:
| Configuration | Mean | Ratio | Allocated |
|---|---|---|---|
| Default implementation | 41.419 ns | 1.00 | 216 B |
| Default + LoggerMessage | 4.004 ns | 0.10 | - |
| AutoLoggerMessage | 4.577 ns | 0.11 | - |
And for ILogger.DefineScope:
| Configuration | Mean | Ratio | Allocated |
|---|---|---|---|
| BeginScope | 39.566 ns | 1.00 | 216 B |
| DefineScope | 5.197 ns | 0.13 | - |
| AutoLoggerMessage | 5.296 ns | 0.13 | - |
Take a look at benchmark page for more details.
EventId parameter. If you pass the explicit EventId parameter, which basically no one does
as far as I can tell, it generates a new EventId and the existing one will be passed to the formatter state, but it
won't be logged.
This limitation comes from the original LoggerMessage generator as they don't support the explicit parameter ~~
yet~~.Log.Define supports only 6 message
parameters (src)
so if you pass more than that, the default Logger.Log(*, params object[] args) will be executed.Logger.Log(*, params object[] args) will be executed.If something is not working as expected, you can fall back on the default implementation of ILogger extensions. To do this, call the extensions directly, for example:
logger.LogInformation("Some message"); // instead of this
LoggerExtensions.LogInformation(logger, "Some message"); // use this
In such case, the source generator will bypass the log call, ensuring you get the expected behavior.
If you require functionality from the LoggerMessage source generator that is not supported by this library,
you can manually create your own source-generated version. Simply define your own partial class and partial method, annotated with the [LoggerMessage] attribute.
logger.LogInformation("Some message"); // instead of this
[LoggerMessage(LogLevel = LogLevel.Information, Message = "Some message")]
public partial void LogSomeMessage(); // use this
But for both scenarios, itβs recommended to report the issue, as it shouldn't happen under normal circumstances. Your feedback can help improve the library and address potential shortcomings. Thank you!
Source-generated logging is increasingly recognized as a modern and efficient approach. Check this page to see why.
But letβs be real, when youβve got a mid-sized project, migrating to the new logging approach is not exactly a simple task. And even when starting a new project, marking every class as partial or depending on an external partial class for logging messages can feel disconnected from the code where they are actually used.
This library handles most of the heavy lifting for you, so you can spend your time doing more important things!
But I hope this is a temporary solution β maybe one day, something similar will be added to the core library. Check this discussion for updates.
This source generator searches for all logger.Log* methods in your code and, based on their parameters, automatically
creates partial methods for LoggerMessage. It also generates a set of interceptors to forward
the logging calls to the newly generated LoggerMessage methods.
For more details, see the How It Works documentation
I bet you have some questions about why things are set up the way they are. Refer to the ADR files for detailed explanations of the design decisions behind this package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on stbychkov.AutoLoggerMessage:
| Package | Downloads |
|---|---|
|
Reo.Core.DataModels
Package Description |
|
|
Reo.Core.Validation
Package Description |
|
|
Reo.Core.Hosting
Package Description |
|
|
Reo.Core.Queue.Abstractions
Package Description |
|
|
Reo.Core.HealthCheck
Package Description |
Showing the top 1 popular GitHub repositories that depend on stbychkov.AutoLoggerMessage:
| Repository | Stars |
|---|---|
|
vknet/vk
Vkontakte API for .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.15 | 230,717 | 12/6/2025 |
| 1.0.14 | 369,604 | 9/10/2025 |
| 1.0.13 | 84,583 | 8/16/2025 |
| 1.0.12 | 66,301 | 7/26/2025 |
| 1.0.11 | 78,371 | 6/16/2025 |
| 1.0.10 | 21,564 | 4/20/2025 |
| 1.0.9 | 610 | 1/29/2025 |
| 1.0.9-beta1 | 190 | 1/29/2025 |
| 1.0.8 | 242 | 1/21/2025 |
| 1.0.7 | 223 | 1/21/2025 |
| 1.0.7-beta.1 | 129 | 1/21/2025 |
| 1.0.6 | 254 | 12/19/2024 |
| 1.0.5 | 225 | 12/3/2024 |