'MassTransit Azure Service Bus log level

I am work on a .net + Xamarin project. I am using MassTransit and Azure Service Bus. When I check the logs, I found the message "Starting Bus: {ConnectionString}" is being logged as Debug. However, the message "Bus Started: {ConnectionString}" is being logged as Information. There is no code for it, so I assume that is what the framework is. I want to change "Bus Started" to Debug logging level. Only this one not all. Can someone help to clarify how to configure this. Below is how I configured before.

 builder
            .AddMassTransit(x =>
            {
                x.UsingAzureServiceBus((context, cfg) =>
                {
                    var configuration = context.GetService<IConfiguration>();
                    var connectionString = configuration["ConnectionStrings:ServiceBus"];
                    cfg.Host(connectionString);


Solution 1:[1]

I want to check all to Debug logging level. Can someone help to clarify how to configure this.

You can try either of the following ways:

1. Using Serilog:

public static IHostBuilder CreateHostBuilder(string[] args)
{
    return Host.CreateDefaultBuilder(args)
        .UseSerilog((host, log) =>
        {
            if (host.HostingEnvironment.IsProduction())
                log.MinimumLevel.Information();
            else
                log.MinimumLevel.Debug();

            log.MinimumLevel.Override("Microsoft", LogEventLevel.Warning);
            log.MinimumLevel.Override("Quartz", LogEventLevel.Information);
            log.WriteTo.Console();
        })
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        });
}

2. Using LogLevel.Debug or Log.Debug

.AddLogging(configure =>
            {
                configure.AddFilter("MassTransit", LogLevel.Debug);
                configure.AddSimpleConsole(options =>
                {
                    options.UseUtcTimestamp = true;
                    options.TimestampFormat = "HH:mm:ss.fff ";
                });
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context,
            CancellationToken cancellationToken = default)
        {
            var busHealth = _busControl.CheckHealth();
            Log.Debug("Bus health:" + busHealth.Status);
            foreach (var queueName in QueueNames)
            {
                Log.Debug($"Health checking {queueName}");
                var endpoint = await _busControl.GetSendEndpoint(new Uri("queue:" + queueName));
                Log.Debug($"Health check ok");
            }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1