Exception caught when writing error log to fileSystem.IO.IOException: Read-only file system : '/var/task/aws-logger-errors.txt' #202
-
Describe the bugI've introduced serilog to some AWS lambda I wrote... when I run them I got this... any suggestion? Here's my code
and when I log it's something as
Any suggestion? Expected BehaviorThe fact that the logs are correcly written to the CloudWatch Current BehaviorThis error is written in cloudwatch but no other application logs are written Reproduction Stepssee up Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWS Lambda core 2.1.0 Targeted .NET Platform.NET6 Operating System and versionWindows 10 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Hi @pponzano, Good morning. Could you please share your This setting is typically used for development environment. So you should have this setting enabled instead in Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello,
and here's the .csproj
I've not manually set the Thanks |
Beta Was this translation helpful? Give feedback.
-
I am experiencing the same problem, how did you guys solve it ? This is in {
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
}
},
"Serilog": {
"Using": [
"AWS.Logger.SeriLog"
],
"LogGroup": "/aws/lambda/CustomAPI-Production-ApiHandler",
"Region": "us-east-1",
"MinimumLevel": {
"Default": "Debug"
},
"WriteTo": [
{
"Name": "AWSSeriLog",
"Args": {
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
}
]
}
} And this is is builder.Host.UseSerilog((_, loggerConfig) =>
{
loggerConfig.ReadFrom.Configuration(builder.Configuration);
});
builder.Logging.AddAWSProvider(); I have no other configuration related to logging anywhere else, I don't understand what And then in the CloudWatch logs I only see exceptions It is a aspnet core 6.0 AWS SAM (serverless) application, it has all permissions to write to logs, if I am not using Serilog, all appears properly in CloudWatch Part of the permissions in the - Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Effect: "Allow" EDIT - I've mitigated it by not using {
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog",
"textFormatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
}
],
"Properties": {
"Application": "CustomAPI"
}
}
} What is then the benefit of using |
Beta Was this translation helpful? Give feedback.
-
Facing same issue with "Using": [ but it works with "Using": [ "Serilog.Sinks.Console" ], not sure what is the use of AWS.Logger.SeriLog then. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @pponzano,
Good morning.
Could you please share your
.csproj
file,appSettings.json
and Serilog configuration (if not usingappSettings.json
)? Looks like you haveSerilog:LibraryLogErrors
set totrue
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.Developme…