JSON console log format

Hello!
I’m new to n8n; so forgive any naivety…
Running it locally; i’ve been quite impressed, so I was going to get it deployed.
Ideally I need the application log output to be structure (json) to console (we run on kubernetes, and then use fluent-bit to scrape those logs).

I’m referring to these logs:

Press "o" to open in Browser.
2023-04-06T11:21:09.022Z | info     | 
Stopping n8n... "{ file: 'start.js', function: 'stopProcess' }"
2023-04-06T11:21:09.024Z [Rudder] debug: in flush
2023-04-06T11:21:09.024Z [Rudder] debug: cancelling existing timer...
2023-04-06T11:21:09.024Z [Rudder] debug: cancelling existing flushTimer...
2023-04-06T11:21:09.024Z [Rudder] debug: batch size is 2
2023-04-06T11:21:09.358Z | info     | 
Stopping n8n... "{ file: 'start.js', function: 'stopProcess' }"
2023-04-06T11:21:09.358Z [Rudder] debug: no existing flush timer, creating new one
2023-04-06T11:21:09.358Z [Rudder] debug: in flush
2023-04-06T11:21:09.358Z [Rudder] debug: skipping flush, earlier flush in progress
2023-04-06T11:21:09.434Z | verbose  | Call to remove all active workflows received (removeAll) "{ file: 'ActiveWorkflowRunner.js', function: 'removeAll' }"
2023-04-06T11:21:09.436Z | debug    | Shutting down event writer... "{ file: 'MessageEventBus.js', function: 'close' }"
2023-04-06T11:21:09.437Z | debug    | EventBus shut down. "{ file: 'MessageEventBus.js', function: 'close' }"

Is there any way to make these json, eg {"level":"debug", "timestamp":"...., etc

Thanks

Hi @kstoney - welcome to the community! :tada:

While you wouldn’t be able to do this at a console level, you could set up your n8n environment to log to a file instead. You can find some more information about that here. You can set up your n8n instance to log to both console and file, so hopefully you could have the best of both worlds here!

The output should be exactly what you’re looking for:

{"level":"info","message":"Initializing n8n process","metadata":{"file":"start.js","function":"init","timestamp":"2023-04-12T09:35:31.373Z"}}
{"level":"warn","message":"Migrations finished.","metadata":{"file":"migrationHelpers.js","timestamp":"2023-04-12T09:35:31.484Z"}}

Let me know if that helps!

1 Like