Closed eloisetaylor5693 closed 6 months ago
It looks like you're using next@14
, which we're currently trying to add support for (#22).
Please can you try using the latest beta version of next-logger
, and let me know if it works for you?
npm i next-logger@4.0.0-beta.1
Using the beta version I get this error:
% yarn start
yarn run v1.22.19
$ NODE_OPTIONS='-r next-logger' NODE_ENV=production yarn server
error: uncaughtException: logger.child is not a function
TypeError: logger.child is not a function
at getPinoMethod (..../node_modules/next-logger/lib/patches/next.js:6:30)
Is my next-logger.config.js
setup correctly?
The exported logger
is expected to have a .child
method - which both pino
and winston
do. In your config, you're exporting a plain object with method properties - rather than a winston
instance.
If you export the winston
instance itself, it should work.
// next-logger.config.js
const { createLogger, format, transports } = require('winston');
const logger = createLogger({
level: 'debug',
defaultMeta: { type: 'nextjs' },
transports: [
new transports.Console({
handleExceptions: true,
format: format.combine(format.colorize(), format.simple()),
}),
],
});
module.exports = {
logger,
};
After fixing the config, this works. Thank you
I suggest adding this to the docs, along with perhaps some examples for other popular loggers
When is the version that supports next 14 likely to be released?
Glad it works. I'll try to get it released today, along with a README
update as suggested.
Awesome! Thanks again
Version 4.0.0 has been published, bringing Next 14 support!
It seems the console logs look like they did before I made the change. Do you have advice on how to make this work?
I did the following:
next-logger.config.js
to the root of the project, see belowActual Log output: