Closed fuglu closed 2 years ago
Thanks, will check soon. Also, if you know how to fix feel free to open PR
just checked, pretty strange behavior: if comment this line everything works. So from my point of view, this could be a bug in Nestjs for a specific case when using Adapter
and bufferLogs
is set. This can be checked with dummy logger implementation
so as a workaround you can disable logs buffering on startup. Closing but feel free to provide a dummy logger example if you would like to check if this is a bug of nestjs-pino or framework
@fuglu I think we must call app.listen
instead of server.listen
. It works if you do that
I am still having this issue, I unfortunately need to call server.listen
since I am utilizing both an SSL and non-SSL server for my project. Without buffering logs, I can make the app emit logs semi-appropriately, however, logs before a certain point are using the default logger:
Considering opening an issue on the NestJS repository, however, I think this is something that can be addressed within nestjs-pino
?
@128keaton please check if you still see a problem with other loggers (maybe try one from the docs) then this is surely not a bug of the current library. No need to add dirty hacks to handle bugs in the framework. Otherway feel free to open a bug report with the minimal example here.
The listen()
function calls flushLogs()
to clear the logs accumulated in the buffer, but init()
doesn't call it separately. You can call flushLogs()
to do so
[x] I've read the docs of nestjs-pino
[x] I've read the docs of pino
[x] I couldn't find the same open issue of nestjs-pino
What is the current behavior?
Only request logs will be written when using a custom express server. Other
this.logger.log("...")
messages won't show up.What is the expected behavior?
All lines should be logged.
Please provide minimal example repo. Without it this issue will be closed
Simple
npx -p @nestjs/cli nest new my-nest-project
example is over here: https://github.com/fuglu/nestjs-pino-custom-express-serverThe
app.controller.ts
has athis.logger.log('Hello Nest');
line which won't show up.This is the relevant
main.ts
:Please mention other relevant information such as Node.js version and Operating System.
OS: Debian (testing) Node.js: v16.8.0 Nest: v8.0.6 nestjs-pino: v2.2.0
Thanks for creating nestjs-pino!