Closed phoenix741 closed 2 years ago
Hi,
In version 8.4.4 of nestjs log aren't automatically flushed when working in a serverless context.
The code that active autoFlushLogs is only called on the method createApplicationContext
autoFlushLogs
createApplicationContext
if (this.autoFlushLogs) { context.flushLogsOnOverride(); }
The method createMicroservice and create don't call this methods, so the logs are never flushed even if we call with autoFlushLogs: true
createMicroservice
create
When calling flushLogs manually, it's working :
const app = await NestFactory.create(AppModule, { bufferLogs: true }); app.useLogger(app.get(MyLogger)); app.flushLogs(); await app.init() const expressApp = app.getHttpAdapter().getInstance(); return serverlessExpress({ app: expressApp });
Thanks
https://stackblitz.com/edit/nestjs-typescript-starter-vcexx9?file=tsconfig.json
The autoflushLogs should work in all context
No response
8.4.4
"@nestjs/common": "^8.4.4", "@nestjs/core": "^8.4.4",
16
If you use a non-standard approach (serverless express) that doesn't call the listen() method, you have to manually flush logs so this is the expected behavior.
listen()
Is there an existing issue for this?
Current behavior
Hi,
In version 8.4.4 of nestjs log aren't automatically flushed when working in a serverless context.
The code that active
autoFlushLogs
is only called on the methodcreateApplicationContext
The method
createMicroservice
andcreate
don't call this methods, so the logs are never flushed even if we call with autoFlushLogs: trueWhen calling flushLogs manually, it's working :
Thanks
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-vcexx9?file=tsconfig.json
Steps to reproduce
Expected behavior
The autoflushLogs should work in all context
Package
Other package
No response
NestJS version
8.4.4
Packages versions
Node.js version
16
In which operating systems have you tested?
Other
No response