Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ashishsingh9x opened this issue Mar 13, 2020 · 0 comments

Comments

@ashishsingh9x
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant