Logs from some loggers are not synced/flushed
- Dominant language
- Go
- Stars
- 3.8k
- Forks
- 578
- Avg merge
- 8h 18m
- Merged PRs (30d)
- 1
Description
**Issue**: when i use zerolog or zap loggers 60% of time logs are not synced, so they are not displayed in CloudWatch.
**Code of my handler**:
```go
var handlerInitialized = false
var chiAdapter *chiadapter.ChiLambda
var logger *zerolog.Logger
func Handler(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
if !handlerInitialized {
logger = zerolog.New(os.Stderr)
logger.Info("cold_start")
api := server.NewAPI(&logger)
chiAdapter = chiadapter.New(api.Router())
handlerInitialized = true
}
return chiAdapter.Proxy(req)
}
func main() {
lambda.Start(Handler)
}
```
used: https://github.com/awslabs/aws-lambda-go-api-proxy
Half of logs that comes from http Handlers and middlewares are not shown.
I found that only `standard logger` and `https://github.com/apex/log` work correctly.
I already asked this question in many places, and tried to use zap's `logger.Sync()` to flush, but it doesn't help.
Contributor guide
Assessment
This issue has not been assessed yet.