I have code like below. At most places ILogger is injected, but here I used LogManager, assuming it would also use ILogger and log to Application Insights.
I don’t see logs in Application Insights. Is mine assumtion wrong that LogManager is automaticlly configurated to use ILogger under the hood?
If I can’t use LogManager, is there a a built in way in NServiceBus to use ILogger? With Behaviors I can inject it, but is there a way to do it for a RecoverabilityPolicy?
public static class DataverseRecoverabilityPolicy
{
static readonly ILog s_log = LogManager.GetLogger("DataverseRecoverabilityPolicy");
public static RecoverabilityAction Invoke(RecoverabilityConfig config, ErrorContext context)
{
// recoverability logic
// I want to log here
}
}
It is wired up, but only after the generic host initializes it.
This is likely because the logging isn’t configured until after the static ILogger is populated as part of the NServiceBus configuration.
We are working on trying to create a sample that would work in your situation. We will update this thread when we have one for you (or if we are unable to create one).