Feature request - Built-in universal logger #23933
Replies: 5 comments
-
I'm not sure if this issue is Next.js-related, but if you are looking for a logger, definitely check out pino. https://github.com/pinojs/pino/blob/master/docs/benchmarks.md |
Beta Was this translation helpful? Give feedback.
-
Pino is not compatible with Next.js Edit: This relies on a custom server, which over-complexifies things and is not compatible with the Serverless way of running Next.js. Also, logs written in the browser are sent to the server, maybe that's the point of the example, but that's weird. And overriding the logger per page (on the server side) is quite redundant. But indeed it doesn't seem to suffer from a webpack issue. Regardless, it doesn't seem to be a proper alternative for Next.js. |
Beta Was this translation helpful? Give feedback.
-
@Vadorequest that is not correct, pino works well with Next, see https://github.com/pinojs/pino-nextjs-example/pull/1/files as an example. |
Beta Was this translation helpful? Give feedback.
-
or any logger management ui like graylog? |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I'm the author of I wrote
I came up with this solution:
The idea here is a logging facade. It's like slf4j in the Java world. A facade with a generic interface that you back with the logging library of your choice. Currently I am working to get the following working:
It's work in progress... I'm doing it on my own atm... And I don't always have time to work on it. However I really do feel a logging facade is what the Javascript world needs so framework and library vendors can just support any logger easily. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature request
Is your feature request related to a problem? Please describe.
Universal logging that is light and customisable isn't an easy task.
I'm currently using
@unly/utils-simple-logger
, which relies onwinston
(~ 40kB).There are a few limitations with this implementation:
console
and "lies" about where calls are fromconsole.log
API, and cannot be a drop-in replacement for console.logIt has come to my attention through an open issue that Winston was adding about ~60kB to all pages (404 > 344kB without it), and this is a huge difference.
I'm using a custom logger for the following reasons:
Describe the solution you'd like
I believe this could be made available as an external package for those who wish to use it.
What do you use for logging at Next?
Describe alternatives you've considered
I've spent a few hours looking around what alternatives I could use, but after studying about half a dozen of alternatives, I've come short to no viable solution. Either they aren't universal, or too big, or lack features, aren't maintained, etc.
The 2 most interesting alternatives I've found are:
ulog
(formerlypicolog
) - See issue with Next.jsdebug
friendlydebug
- Interesting, but lacks must-have features such as "Logging levels"Overall, ulog looks great, but there are a few important issues and bad design decisions. (Download/ulog#16)
Beta Was this translation helpful? Give feedback.
All reactions