Skip to content
Discussion options

You must be logged in to vote

Hey @Marcosld, our team had a very similar issue until I discovered the experimental.instrumentationHook. You can use this hook in combination with next-logger to console.log JSON rather than plain text. The JSON object even contains the log level and stack trace.

Steps

1. Install package:

npm install next-logger

2. (Option 1) - using standard output

Simply add NODE_OPTIONS to start command:

NODE_OPTIONS='-r next-logger' next start

2. (Option 2) - using output: 'standalone'

If you are specifying output: 'standalone' in your next.config you will need to add an instrumentationHook to ensure that the next-logger module is available at runtime. Without it you will run into the following issue

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Marcosld
Comment options

@Yimiprod
Comment options

@nmiddendorff
Comment options

@Netail
Comment options

@theogravity
Comment options

Answer selected by Marcosld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants