I am using docker-compose and setting the N8N_LOG_FILE_LOCATION variable. I am seeing logs, but not my console.log . Based on this thread it seems like using console.log() is not recommended. I looked through this document and I am still a bit confused. I tried adding the js in a Code node, but I get the error Problem in node ‘Code‘ 'import' and 'export' may only appear at the top level [line 1]
console.log in the Code node outputs the content to the client console, it’s not the server-side feature. console.log or LoggerProxy in the TS code acts differently, but that one is only for debugging issues with the community nodes. You normally should not collect it.
@barn4k ahh I didn’t know that, there wasn’t any mention of community node in there.
Basically, my goal is just to create logs on my workflows that I can look up later. For example, if a http request fails on a scheduled job, i would like to capture the error response message.
Maybe I need to use logging systems like AWS CloudWatch or something? I just wanted to first check if there was something native.
You will see the error in the execution log. It is enabled by default for each workflow. You can also set the error workflow to send the errors somewhere (splunk, database, email, etc) and attach that workflow inside the desired workflows in the settings section.
The best approach is to set the error workflow(s). n8n logs are needed for internal purposes or n8n debug when something strange is happening.