{"id":24600716,"url":"https://github.com/stbychkov/AutoLoggerMessage","last_synced_at":"2025-10-05T21:31:54.067Z","repository":{"id":266059698,"uuid":"895070264","full_name":"stbychkov/AutoLoggerMessage","owner":"stbychkov","description":"A source generator that automatically migrates your logging calls to the LoggerMessage version","archived":false,"fork":false,"pushed_at":"2025-09-10T23:30:32.000Z","size":2560,"stargazers_count":104,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-11T02:57:45.882Z","etag":null,"topics":["csharp","dotnet","logging","roslyn","source-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stbychkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"patreon":"stbychkov","ko_fi":"stbychkov","buy_me_a_coffee":"stbychkov","thanks_dev":"stbychkov"}},"created_at":"2024-11-27T14:03:01.000Z","updated_at":"2025-09-10T23:27:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"91c1735c-cecd-4ecb-85bf-6da148947168","html_url":"https://github.com/stbychkov/AutoLoggerMessage","commit_stats":null,"previous_names":["stbychkov/autologgermessage"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/stbychkov/AutoLoggerMessage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stbychkov%2FAutoLoggerMessage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stbychkov%2FAutoLoggerMessage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stbychkov%2FAutoLoggerMessage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stbychkov%2FAutoLoggerMessage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stbychkov","download_url":"https://codeload.github.com/stbychkov/AutoLoggerMessage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stbychkov%2FAutoLoggerMessage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278525555,"owners_count":26001321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","logging","roslyn","source-generator"],"created_at":"2025-01-24T14:01:24.644Z","updated_at":"2025-10-05T21:31:54.062Z","avatar_url":"https://github.com/stbychkov.png","language":"C#","funding_links":["https://patreon.com/stbychkov","https://ko-fi.com/stbychkov","https://buymeacoffee.com/stbychkov","https://thanks.dev/stbychkov"],"categories":["Recently Updated","Contributors Welcome for those","Source Generators","Logging","Parsing"],"sub_categories":["[Jan 30, 2025](/content/2025/01/30/README.md)","1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category","Other","GUI - other"],"readme":"# AutoLoggerMessage\n\n[![NuGet](https://img.shields.io/nuget/v/stbychkov.AutoLoggerMessage)](https://www.nuget.org/packages/stbychkov.AutoLoggerMessage/)\n![Build](https://github.com/stbychkov/AutoLoggerMessage/actions/workflows/dotnet_build.yml/badge.svg)\n[![License](https://img.shields.io/github/license/stbychkov/AutoLoggerMessage)](https://github.com/stbychkov/AutoLoggerMessage/blob/main/LICENSE)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/stbychkov.AutoLoggerMessage)](https://www.nuget.org/packages/stbychkov.AutoLoggerMessage/)\n[![PRs Welcome](https://img.shields.io/badge/PR-Welcome-blue)](https://github.com/stbychkov/stbychkov.AutoLoggerMessage/pulls)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/stbychkov/AutoLoggerMessage)\n\n---\n\nWelcome to `AutoLoggerMessage`, a source generator that automatically creates [`LoggerMessage`](https://youtu.be/Otm8tH0Vrp0) methods, enabling high-performance logging.\n\n## Demo\n\nClick the image below to watch the demo video:\n\n[![Demo](https://raw.githubusercontent.com/stbychkov/AutoLoggerMessage/c4ffa42eab74b75bac814a2beca374893f845a2f/src/AutoLoggerMessageGenerator/Assets/icon.jpg)](https://youtu.be/2MTbv6WtwjM?si=lGVfp3Sz8h2B1b-U)\n\n## Getting started\n\n#### Install the Package from [NuGet](https://www.nuget.org/packages/stbychkov.AutoLoggerMessage)\n\n```shell\ndotnet add package stbychkov.AutoLoggerMessage\n```\n\nCheck [this](https://github.com/stbychkov/AutoLoggerMessage/wiki/Configuration) page for configuration options that can tweak the source generation process.\n\n## Benchmarks\n\nYou can achieve performance boosts of up to 90% just by including this source generator in your project.\n\nFor `ILogger.Log*` methods:\n\n| Configuration           | Mean      | Ratio | Allocated |\n|-------------------------|-----------|-------|-----------|\n| Default implementation  | 41.419 ns | 1.00  | 216 B     |\n| Default + LoggerMessage | 4.004 ns  | 0.10  | -         |\n| AutoLoggerMessage       | 4.577 ns  | 0.11  | -         |\n\nAnd for `ILogger.DefineScope`:\n\n| Configuration           | Mean      | Ratio | Allocated |\n|-------------------------|-----------|-------|-----------|\n| BeginScope              | 39.566 ns | 1.00  | 216 B     |\n| DefineScope             | 5.197 ns  | 0.13  | -         |\n| AutoLoggerMessage       | 5.296 ns  | 0.13  | -         |\n\nTake a look at [benchmark](https://github.com/stbychkov/AutoLoggerMessage/wiki/Benchmarks) page for more details.\n\n## Known Limitations\n\n* It supports only static `EventId` parameter. If you pass the explicit `EventId` parameter, which basically no one does\n  as far as I can tell, it generates a new `EventId` and the existing one will be passed to the formatter state, but it\n  won't be logged.\n  This limitation comes from the original `LoggerMessage` generator as they don't support the explicit parameter ~~\n  yet~~.\n* `Log.Define` supports only 6 message\n  parameters ([src](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loggermessage.define))\n  so if you pass more than that, the default `Logger.Log(*, params object[] args)` will be executed.\n* As this solution is based on interceptors, only .NET 8+ is supported\n* Generic arguments [are not supported](https://github.com/dotnet/extensions/blob/ca2fe808b3d6c55817467f46ca58657456b4a928/docs/list-of-diagnostics.md?plain=1#L66C4-L66C13). If you pass a generic argument to the log function, the default `Logger.Log(*, params object[] args)` will be executed.\n\n## Is something wrong?\n\nIf something is not working as expected, you can fall back on the default implementation of ILogger extensions.\nTo do this, call the extensions directly, for example:\n\n```csharp\nlogger.LogInformation(\"Some message\"); // instead of this\nLoggerExtensions.LogInformation(logger, \"Some message\"); // use this\n```\n\nIn such case, the source generator will bypass the log call, ensuring you get the expected behavior.\n\nIf you require functionality from the `LoggerMessage` source generator that is not supported by this library,\nyou can manually create your own source-generated version. Simply define your own partial class and partial method, annotated with the [LoggerMessage] attribute.\n\n```csharp\nlogger.LogInformation(\"Some message\"); // instead of this\n\n[LoggerMessage(LogLevel = LogLevel.Information, Message = \"Some message\")]\npublic partial void LogSomeMessage(); // use this\n```\n\nBut for both scenarios, it’s recommended to report the issue, as it shouldn't happen under normal circumstances.\nYour feedback can help improve the library and address potential shortcomings. Thank you!\n\n## Motivation\n\nSource-generated logging is increasingly recognized as a modern and efficient approach. Check [this](https://github.com/stbychkov/AutoLoggerMessage/wiki/Evolution-of-Logging-Techniques) page to see why.\n\nBut let’s be real, when you’ve got a mid-sized project, migrating to the new logging approach is not exactly a simple\ntask. And even when starting a new project, marking every class as partial or depending on an external partial class for\nlogging messages can feel disconnected from the code where they are actually used.\n\nThis library handles most of the heavy lifting for you, so you can spend your time doing more important things!\n\nBut I hope this is a temporary solution — maybe one day, something similar will be added to the core library.\nCheck [this](https://github.com/dotnet/runtime/discussions/110364) discussion for updates.\n\n## How It Works\n\nThis source generator searches for all `logger.Log*` methods in your code and, based on their parameters, automatically\ncreates partial methods for `LoggerMessage`. It also generates a set of interceptors to forward\nthe logging calls to the newly generated `LoggerMessage` methods.\n\nFor more details, see the [How It Works](https://github.com/stbychkov/AutoLoggerMessage/blob/main/docs/how-it-works.md)\ndocumentation\n\n## Questions?\n\nI bet you have some questions about why things are set up the way they are.\nRefer to the [ADR files](https://github.com/stbychkov/AutoLoggerMessage/tree/main/docs/ADR) for detailed explanations of the design decisions behind this package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstbychkov%2FAutoLoggerMessage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstbychkov%2FAutoLoggerMessage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstbychkov%2FAutoLoggerMessage/lists"}