CloudWatchAppender icon indicating copy to clipboard operation
CloudWatchAppender copied to clipboard

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

Open ashishsingh9x opened this issue 4 years ago • 0 comments

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.

ashishsingh9x avatar Mar 13 '20 20:03 ashishsingh9x