Skip to content

Log4Net logging on cloudwatch when the build is debug mode but it is logging in aws-logger-errors.txt in release mode. #29

@ashishsingh9x

Description

@ashishsingh9x

Project is console application in c# using visual studio
Here is the code:

private void ConfigureLog4net()
{
string convertionPattern = "%-4timestamp [%thread] %-5level %logger %ndc - %message%newline";

    string region = "us-east-1";

    string loggerAWSAccessKey = "myawsaccesskey";

    string loggerAWSSecretKey = "myawssecretkey";

    Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
    PatternLayout patternLayout = new PatternLayout {ConversionPattern = convertionPattern};

    patternLayout.ActivateOptions();

    var appender = new AWSAppender
    {
        Layout = patternLayout,
        Credentials = new BasicAWSCredentials(loggerAWSAccessKey, loggerAWSSecretKey),
        LogGroup = ConfigurationManager.AppSettings["LogGroup"],
        Region = region
    };

    // Set log group and region. Assume credentials will be found using the default profile or IAM credentials.

    appender.ActivateOptions();
    hierarchy.Root.AddAppender(appender);

    hierarchy.Root.Level = Level.All;
    hierarchy.Configured = true;
}

This is working with some console application on EC2 instance but not in 1-2 console app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions