Closed SeoYoung-C closed 2 months ago
In my own experience, next-logger doesn't work with Winston out of the box even though the doc has instructions to do so. There are multiple issues:
next-logger.config.js
needs to be a function, otherwise the library will fall back to the default Pino logger. This means you need to export a function which takes the defaultPinoConfig
from the library as an input, merge it with your own logger config and returns the Winston loggertrace
, which Winston doesn't haveI didn't try to find a way to patch Winston to solve 2 as it is too hacky, and ended up using Pino instead, which claim to have better performance, and so far works well in my simple case (output log to console with necessary info and is structured)
As for the 14.2.1 module loading problem, I haven't root caused the issue yet, but that's how I found your question while doing the research.
Finally find out a workaround for the module loading problem starting from 14.2, see https://github.com/sainsburys-tech/next-logger/issues/13#issuecomment-2113625702
Because of the issues above, struggling hard to make my 3rd party service that only has winston-transport and I couldn't find way to create a new custom pino transport for them, this library has proven itself not working even though it was really promising for a nextjs logging solution.
Hello, I'm using a standalone build. I want to use the winston module along with the next-logger library and capture the console. I'm using the app router approach. In the app router approach, there's an issue where the winston module gets removed during the build, so I'm adding a config to ensure it's deployed correctly even in standalone builds. The problem I've identified is that when using the latest version of next.js, version 14.2.1, an error occurs in development mode stating that next-logger.config.js of next-logger cannot be found.
You can find this error on the main branch of the following address: https://github.com/SeoYoung-C/next-logger-issue.git
And the second issue is that after downgrading my next version to 14.1.x, I can see the problem. I want to use the winston logger library. Following the guide provided in the next-logger, when I add the winston logger and apply ecsformat, it seems to not respond at all and just default values. You can check this on the next-14.1.4 branch.
I'm wondering if there's a solution to this.