Can not log exceptions

I’ve implemented a custom logger in my ASP.NET Framework project using the ILog and ILogProvider interfaces. However, I’ve come across an issue where, following an exception, it fails to enter the Log function within the custom logger. I’m curious about the reason behind this behavior and how I can effectively log thrown exceptions in this scenario.

Additionally, it periodically re-enters the custom logger with the LogLevel set to Trace every 5 seconds.

Thanks in advance for your assistance.

public class HangfireLoggerAdapter : ILog
{
    public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null)
    {
        if (messageFunc == null)
        {
            return logLevel >= LogLevel.Info;
        }

        // inserting exception into database

        return true;
    }
}


public class HangfireLogProvider : ILogProvider
{
    public ILog GetLogger(string name)
    {
        return new HangfireLoggerAdapter();
    }
}

private IEnumerable<IDisposable> GetHangfireServers()
{
    string schemaName = GetHangfireSchemaName();

    string connString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
    GlobalConfiguration.Configuration
        .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
        .UseSimpleAssemblyNameTypeSerializer()
        .UseRecommendedSerializerSettings()
        .UseSqlServerStorage(connString, new SqlServerStorageOptions
        {
            SchemaName = schemaName,
        })
        .UseFilter(new AutomaticRetryAttribute { Attempts = 0 })
        .UseLogProvider(new HangfireLogProvider());

    yield return new BackgroundJobServer();
}