I see that the Log section of n8n docs has a blurb on how to set up LoggerProxy however I struggle to understand the specifics behind the setup.
Context: I am working in a self-hosted environment
Let’s say I create a ts class to log what is going on in a workflow, am I importing the LoggerProxy from the workflow or from an n8n node inside of the workflow?
The documentation is a bit vague on the specifications for setting up a custom Logger. Similarly, there is no location where the parameters for the LoggerProxy function are defined. Is it assumed the developer is going through n8n source code to determine these parameters?
I would love to update the documentation with answers to these questions assuming im not dense and missing something obvious.
Thank you!
I’m also having a little trouble getting the logging to behave as expected.
Using this in a custom node doesn’t throw any compile or runtime errors, but nothing seems to be written to the log.
import { LoggerProxy as Logger } from 'n8n-workflow';
// ... other code ...
Logger.info(`Input items: ${items.toString()}`);
As far as I know, I have followed instructions to configure things correctly per: “Logging in n8n” documentation but I’m not seeing my log messages when the code is executed. I’ve tried logging plain strings too (in case it was related to some sort of string variable resolution issue). The default config should output Logger.info() calls to the console, but the last thing I see is the => Started ...
startup message.
Hoping someone will see this and let me know if there’s something else missing from the documentation (or if it’s there, and I just missed it).
I have partially resolved this myself, although it doesn’t address the no-op behavior of LoggerProxy.
For those attempting to output log messages from their Custom Node code, there is an inherited field in scope, within the MyCustomNode.node.ts source/object, named logger
, that actually works (as of approximately version 1.50.x, and possibly earlier versions).
So, to write log messages as configured in the n8n settings (output, level, etc.), call this.logger.debug("message text")
, or one of the other level based functions (error(), warn(), info(), etc.).
1 Like