HangfireIO / HangfireIO/Hangfire
AutomaticRetryAttribute & LogProvider
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
I've just run in to a small issue that took a little bit of tracking down involving logging. I was trying to set the logging provider through the `.UseLogProvider` method of `GlobalConfiguration` to an aggregated logger so I could push errors through to `RayGun`.
The problem was before calling this method I had referenced the `GlobalFilters` class which instantiates an instance of `AutomaticRetryAttribute`. This creates and stores the logger to be used, but is done _before_ I had registered a new logger.
I've worked around the issue by calling `LogProvider.SetCurrentLogProvider` before doing any other configuration but this could be problematic for anyone doing similar.
Can the use of the logger be changed to be lazy so it's created on first use which should be after all configuration
Also, related, could we have a means of reporting errors that is not just through a logging provider, a centralised way of exception logging / handling to have a slightly more natural integration for this use-case?
Thanks, Adam
Contributor guide
Research direction
Start by tracing GlobalFilters, AutomaticRetryAttribute, and GlobalConfiguration.UseLogProvider to see when the logger is created and configured. Review the existing LogProvider.SetCurrentLogProvider workaround. Done means logger creation no longer depends on configuration order and the requested centralized exception-reporting path has a defined, tested integration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100