-
Notifications
You must be signed in to change notification settings - Fork 27
Support automatic log forwarding in next's app dir #126
Comments
Did you find any solution to send your logs ? |
Not very encouraging:
Can someone from NewRelic please give more information or a timeline? Thanks. |
We switched to OpenTelemetry as it's integrated with Next.js |
We also did this, although the OTEL data is nowhere near as rich as the full NewRelic integration. Not super useful TBH. |
@kdembowski I took a look at this and it's because Next.js is using webpack to bundle dependencies. We have an experimental plugin that can be used to fix issues that webpack causes but it appears to conflict with some of the other packages that Next.js relies on. To get winston working or really any library to instrument. Add this to next.config.js
By doing this I see your log lines in my app ![]() |
I'm going to close this. Please let me know if this does not work for you and we can reopen. I also introduced a PR to make this easier by automatically externalizing all libraries the Node.js agent instruments |
Is your feature request related to a problem? Please describe.
Automatic (possibly manual as well) log forwarding does not seem to work in /app dir (considered stable since next 13.4).
Feature Description
Support for automatic log forwarding inside /app directory.
Describe Alternatives
N/A
Additional context
I was struggling to set up logging for a Next application using its new app router. It appears that automatic log forwarding simply does not work in React Server Components. Following newrelic's documentation I expected it to automatically forward logs when using a supported logger - I've tried both Winston and Pino. I've also tried manual logging with enricher plugins but as I understand they are not needed/deprecated(?)
To verify the issue is not in my setup I've created 2 basic Next.js repos - one using old /pages and one using new app router. For the one with /pages logs were forwarded completely fine when logging from
getServerSideProps
. However for /app when logging from any server component it is not forwarded.Here are the repos:
/pages: https://github.com/kdembowski/newrelic-pages-repro/blob/main/pages/index.tsx
/app: https://github.com/kdembowski/newrelic-app-router-repro/blob/main/src/app/page.tsx
Priority
Must Have
The text was updated successfully, but these errors were encountered: