Microsoft.Extension.Logging ILogger access can be source generated to improve performance. There are several styles that can be used:
- static "Log" partial class with static extension methods for ILogger (at end of file or one per area/namespace)
- instance log partial class Adapter/Decorator with an ILogger taking constructor and ILogger member.
Preference is option 1. with one static class per existing file (at the end).
There shall be one "internal static class EventIds" class at the root of each project with the public const offsets centrally managed, and each static log class having its log methods start at the offset constant + <number of log message, 0 based>. This allows managing and documenting the event ids via their offsets in a central place. Each offset constant should leave 5 slots for adding additional log messages in the future and then round up to the nearest multiple of 10.
Microsoft.Extension.Logging ILogger access can be source generated to improve performance. There are several styles that can be used:
Preference is option 1. with one static class per existing file (at the end).
There shall be one "internal static class EventIds" class at the root of each project with the public const offsets centrally managed, and each static log class having its log methods start at the offset constant + <number of log message, 0 based>. This allows managing and documenting the event ids via their offsets in a central place. Each offset constant should leave 5 slots for adding additional log messages in the future and then round up to the nearest multiple of 10.