Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Exception caught when writing error log to fileSystem.IO.IOException: Read-only file system : '/var/task/aws-logger-errors.txt' #201

Closed
pponzano opened this issue May 11, 2022 · 1 comment
Labels
guidance Question that needs advice or information. module/logging response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@pponzano
Copy link

Describe the bug

I've introduced serilog to some AWS lambda I wrote... when I run them I got this... any suggestion?

Here's my code

  public static void InitializeLogger()
        {
            AWSLoggerConfig configuration = new AWSLoggerConfig();

            Log.Logger = new LoggerConfiguration()
                .WriteTo.AWSSeriLog(configuration)
                .CreateLogger();

            var serviceCollection = new ServiceCollection();
            ConfigureServices(serviceCollection);

            serviceCollection.AddLogging(loggingBuilder =>
                loggingBuilder.AddSerilog(dispose: true));
        }

and when I log it's something as

   Log.Logger.Information($"Request inserted with Token: {guid}\n");

Any suggestion?
Thanks

Expected Behavior

The fact that the logs are correcly written to the CloudWatch

Current Behavior

This error is written in cloudwatch but no other application logs are written

Reproduction Steps

see up

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWS Lambda core 2.1.0

Targeted .NET Platform

.NET6

Operating System and version

Windows 10

@pponzano pponzano added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 11, 2022
@ashishdhingra
Copy link
Contributor

Hi @pponzano,

Good morning.

Could you please share your .csproj file, appSettings.json and Serilog configuration (if not using appSettings.json)? Looks like you have Serilog:LibraryLogErrors set to true in your config. This flag enables Serilog extension to log any service errors to local log file. When executing in Lambda environment, looks like there are some library errors (such as inability to log to CloudWatch logs may be due to lack of permissions) and it's unable to write to this file since Lambda code is executing with /var/task as current directory.

This setting is typically used for development environment. So you should have this setting enabled instead in appSettings.Development.json, not in production appSettings.json.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. guidance Question that needs advice or information. and removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. labels May 11, 2022
@aws aws locked and limited conversation to collaborators May 11, 2022
@ashishdhingra ashishdhingra converted this issue into discussion #202 May 11, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
guidance Question that needs advice or information. module/logging response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants