/n8n-tutorials

How to enable logging in n8n?

Learn how to enable and configure logging in n8n, including setting log levels, output options, log rotation, and troubleshooting for both Docker and non-Docker setups.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to enable logging in n8n?

To enable logging in n8n, you need to configure the N8N_LOG_LEVEL environment variable in your n8n deployment or installation. This controls the verbosity of logs and can be set to different levels such as 'error', 'warn', 'info', 'verbose', or 'debug' depending on how detailed you want the logs to be.

 

Step 1: Understanding n8n Logging Options

 

Before enabling logging in n8n, it's important to understand the different logging options available:

  • N8N_LOG_LEVEL: Controls the verbosity of logs (error, warn, info, verbose, debug)
  • N8N_LOG_OUTPUT: Determines where logs are output (console, file)
  • N8N_LOG_FILE\_FOLDER: Specifies the folder for log files (when file output is selected)

The main environment variable you'll need to set is N8N_LOG_LEVEL, which accepts the following values in order of increasing verbosity:

  • error: Only logs error messages
  • warn: Logs warnings and errors
  • info: Logs general information, warnings, and errors (default)
  • verbose: More detailed information
  • debug: Very detailed debugging information

 

Step 2: Enabling Logging in Docker Deployment

 

If you're running n8n with Docker, follow these steps to enable logging:

Step 2.1: If using docker run command, add the environment variable:

docker run -it --rm \\
  --name n8n \\
  -p 5678:5678 \\
  -e N8N_LOG_LEVEL=debug \\
  n8nio/n8n

Step 2.2: If using Docker Compose, modify your docker-compose.yml file:

version: '3'

services:
  n8n:
    image: n8nio/n8n
    ports:
    - "5678:5678"
    environment:
    - N8N_LOG_LEVEL=debug
    volumes:
    - n8n\_data:/home/node/.n8n

volumes:
  n8n\_data:

Step 2.3: Apply the changes by restarting your Docker container:

docker-compose down
docker-compose up -d

 

Step 3: Enabling Logging in Non-Docker Installation

 

If you've installed n8n directly on your system using npm or other methods:

Step 3.1: For a temporary session, set the environment variable before starting n8n:

export N8N_LOG_LEVEL=debug
n8n start

Step 3.2: To make the setting permanent, add it to your environment configuration:

For Linux/macOS, add to your .bashrc or .profile file:

echo 'export N8N_LOG_LEVEL=debug' >> ~/.bashrc
source ~/.bashrc

For Windows, set the environment variable through System Properties:

setx N8N_LOG_LEVEL "debug"

 

Step 4: Configuring Log Output Location

 

By default, n8n logs to the console. You can change this to log to a file:

Step 4.1: Set the log output to file:

export N8N_LOG_OUTPUT=file

Step 4.2: Specify the folder where log files should be stored:

export N8N_LOG_FILE\_FOLDER=/path/to/your/logs

For Docker, include these environment variables in your docker run command or docker-compose.yml file:

docker run -it --rm \\
  --name n8n \\
  -p 5678:5678 \\
  -e N8N_LOG_LEVEL=debug \\
  -e N8N_LOG_OUTPUT=file \\
  -e N8N_LOG_FILE\_FOLDER=/home/node/.n8n/logs \\
  -v n8n\_data:/home/node/.n8n \\
  n8nio/n8n

 

Step 5: Customizing Log Rotation Settings

 

For log file rotation, you can configure additional settings:

Step 5.1: Set the maximum file size for log rotation:

export N8N_LOG_FILE_MAX_SIZE=10m

Step 5.2: Configure the number of log files to keep:

export N8N_LOG_FILE_MAX_FILES=5

These settings will create log files that rotate when they reach 10MB, keeping the 5 most recent files.

 

Step 6: Verifying Logging is Enabled

 

After configuring logging, verify that it's working correctly:

Step 6.1: Check if logs are being generated:

For console output:

# The logs should appear in your terminal where n8n is running

For file output:

ls -la /path/to/your/logs
# or if using Docker
docker exec n8n ls -la /home/node/.n8n/logs

Step 6.2: View the log contents:

cat /path/to/your/logs/n8n.log
# or if using Docker
docker exec n8n cat /home/node/.n8n/logs/n8n.log

 

Step 7: Triggering Actions to Generate Logs

 

To see logging in action, perform some operations in n8n:

Step 7.1: Execute a workflow in n8n.

Step 7.2: Check the logs to see detailed information about the execution:

tail -f /path/to/your/logs/n8n.log
# or if using Docker
docker exec n8n tail -f /home/node/.n8n/logs/n8n.log

 

Step 8: Advanced Logging Configuration

 

For more advanced logging needs, n8n supports additional configuration:

Step 8.1: Enable workflow execution logs specifically:

export N8N_WORKFLOW_EXEC_LOG_ENABLED=true

Step 8.2: Specify the level for workflow execution logs:

export N8N_WORKFLOW_EXEC_LOG_LEVEL=debug

Step 8.3: Configure the timeout for workflow execution logs:

export N8N_WORKFLOW_EXEC_LOG_TIMEOUT=30000

This will keep workflow execution logs for 30 seconds.

 

Step 9: Troubleshooting Logging Issues

 

If you're having trouble with n8n logs:

Step 9.1: Verify environment variables are set correctly:

env | grep N8N\_LOG

Step 9.2: Check file permissions if using file output:

ls -la /path/to/your/logs
# Ensure the user running n8n has write permissions to this directory

Step 9.3: If using Docker, check that volumes are mounted properly:

docker inspect n8n | grep Mounts -A 20

 

Step 10: Implementing Logging in Production Environment

 

For production deployments, consider these best practices:

Step 10.1: Use appropriate log levels:

  • Development: Use 'debug' for detailed troubleshooting
  • Production: Use 'info' or 'warn' to reduce log volume

Step 10.2: Set up proper log rotation:

export N8N_LOG_OUTPUT=file
export N8N_LOG_FILE\_FOLDER=/path/to/your/logs
export N8N_LOG_FILE_MAX_SIZE=100m
export N8N_LOG_FILE_MAX_FILES=10

Step 10.3: Consider integrating with a centralized logging system by forwarding n8n logs to services like ELK Stack, Graylog, or Splunk.

 

Step 11: Monitoring Logs for Issues

 

Set up monitoring to alert you about important log events:

Step 11.1: Create a simple script to check for error logs:

#!/bin/bash
if grep -i "error" /path/to/your/logs/n8n.log | tail -n 100 | grep -q .; then
  echo "Errors found in n8n logs"
  # Add notification command here (email, Slack, etc.)
fi

Step 11.2: Set the script to run periodically using cron:

crontab -e
# Add the following line to check every 15 minutes
_/15 _ _ _ \* /path/to/check_n8n_logs.sh

By following these steps, you'll have comprehensive logging enabled in your n8n installation, allowing you to monitor workflow executions, troubleshoot issues, and maintain a healthy n8n environment.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022