This is a Next.js project bootstrapped with create-next-app
and setting up New Relic following this official guide.
According to this doc we are able to monitor the application using AMP agents and logs in context will be automatilcally forwarded using Pino.
Preload New Relic
"dev": "NODE_OPTIONS='-r @newrelic/next' next dev",
Write some logs on page.tsx Setup Pino
import pino from 'pino';
export const logger = pino();
Instrument Pino
properly in next.config.mjs
webpack: (config) => {
if (config.target.includes('node')) {
config.externals.push('pino');
}
return config;
};
Write logs
logger.info('Hi from Next.js - Home');
Run the application providing name and license key by env
variables.
NEW_RELIC_LICENSE_KEY=[your license here] NEW_RELIC_APP_NAME=nextjs-pino npm run dev