Steeltoe
Steeltoe copied to clipboard
[QUESTION] Using Microsoft.Extensions.Logging with Config Server
Question
How can i pass my logger which is of Microsoft.Extensions.Logging into AddConfigServer so that the logs from the config server configuration provider is in a consistent manner with the rest of my logs.
Environment (please complete the following information):
- .NET 8
- Steeltoe Version 3.2.6
Additional context or links
Add any other context about the problem here.
Due to the way Configuration providers integrate with the any of the hosts Microsoft offers, you have to build a separate ILoggerFactory for use before the shared one is available. There are a couple of ways to do this here:
- As we have documented, (build a separate, custom LoggerFactory just for startup)
- There is an
IHostedServicethat is automatically added from the HostBuilder extensions, or can be added withAddConfigServerServices()which will replace this startup LoggerFactory with your common logging configuration once it is available
- There is an
- Use BootstrapLoggerFactory.Instance, optionally adding the
BootstrapLoggerHostedServiceso that your common logging configuration can be applied once it is available
Thanks @TimHess that has been super helpful, i has missed the logger factory option.