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.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
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:
The main environment variable you'll need to set is N8N_LOG_LEVEL, which accepts the following values in order of increasing verbosity:
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:
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.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.