Skip to content

Version 4.0.1 causes logging to fail #340

@Pyrhos

Description

@Pyrhos

Describe the bug

After package upgrade from version 4.0.0 to 4.0.1, logging continues to work for a short period, then stops entirely. Both Network TX and CPU load skyrocket, presumably from repeated attempts at sending logs. Logging does not recover until another deployment is made, at which point the same pattern manifests.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Logging continues to work indefinitely as before.

Current Behavior

A reduced amount of logs get through for up to 2 hours after a deployment finishes. Due to reliance on this form of logging exclusively, there is no other logs I can provide as to the cause of the issue - environmental logs show nothing of note.

Reverting to 4.0.0 without any other changes fixes the issue.

Reproduction Steps

public static void ConfigureLogging(this WebApplicationBuilder builder)
{
    var services = builder.Services;
    var configuration = builder.Configuration;
    var logGroup = "LogGroup";
    var awsOptions = configuration.GetAWSOptions();


    //Note that both environments exhibit the same behavior
    var environment = "Release";
    switch (environment)
    {
        case "Debug":
            services.AddSerilog(s => SetupLogger(s, logGroup, awsOptions)
                .WriteTo.Console(
                    new MessageTemplateTextFormatter(
                        "[{Timestamp:HH:mm:ss} {Level:u3}] [Id:{CorrelationId}, IdentityId:{IdentityId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}")));
            break;
        case "Release":
            services.AddSerilog(s => SetupLogger(s, logGroup, awsOptions));
            break;
    }
}

private static LoggerConfiguration SetupLogger(LoggerConfiguration config, string logGroup, AWSOptions awsOptions) =>
    config
        .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
        .MinimumLevel.Override("Microsoft.Extensions", LogEventLevel.Information)
        .MinimumLevel.Override("Microsoft.AspNetCore.Server.Kestrel", LogEventLevel.Information)
        .MinimumLevel.Override("Hangfire", LogEventLevel.Warning)
        .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
        .Enrich.FromLogContext()
        .Enrich.WithMachineName()
        .Destructure.JsonNetTypes()
        .MinimumLevel.Information()
        .WriteTo.AWSSeriLog(
            new AWSLoggerConfig
            {
                LogGroup = logGroup,
                Credentials = awsOptions.Credentials,
                Region = awsOptions.Region.SystemName,
            },
            textFormatter: new RenderedCompactJsonFormatter(),
            restrictedToMinimumLevel: LogEventLevel.Information);

Possible Solution

No response

Additional Information/Context

Reproducible on AWS ECS and AWS Apprunner

AWS .NET SDK and/or Package version used

AWS.Logger.SeriLog 4.0.1
AWSSDK.Core 4.0.1
Serilog 4.3.0
Destructurama.JsonNet 4.0.2

Targeted .NET Platform

.NET 9

Operating System and version

Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions