# How to Enable Logging in n8n

- Tool: n8n
- Difficulty: Beginner
- Time required: 10 minutes
- Compatibility: n8n 1.0+ (self-hosted and Docker)
- Last updated: March 2026

## TL;DR

Enable logging in n8n by setting the N8N_LOG_LEVEL environment variable to debug, info, warn, or error. You can output logs to the console or a file by configuring N8N_LOG_OUTPUT and N8N_LOG_FILE_LOCATION. This helps you trace workflow failures, API errors, and node execution issues in real time.

## Why Enable Logging in n8n

By default, n8n only logs errors to the console. When workflows fail silently or nodes return unexpected results, you need more visibility. Enabling detailed logging lets you see every HTTP request, credential lookup, and node execution step. This is essential for debugging production workflows, diagnosing API connectivity issues, and understanding why triggers are not firing. n8n supports four log levels and two output targets, giving you full control over verbosity and storage.

## Before you start

- A running self-hosted n8n instance (npm or Docker)
- Access to the server terminal or Docker configuration
- Basic familiarity with environment variables
- Permission to restart the n8n process

## Step-by-step guide

### 1. Set the log level environment variable

n8n reads the N8N_LOG_LEVEL environment variable at startup. The four levels are error (least verbose), warn, info, and debug (most verbose). For troubleshooting, start with info to see execution flow without overwhelming detail. Use debug only when you need to inspect HTTP request bodies and credential resolution. Set the variable before starting n8n. On Linux or macOS, export it in your shell session or add it to your .env file.

```
# Set log level to info (recommended for troubleshooting)
export N8N_LOG_LEVEL=info

# Or for maximum detail during debugging
export N8N_LOG_LEVEL=debug

# Then start n8n
n8n start
```

**Expected result:** n8n starts and prints detailed log messages to the console, including node execution events and HTTP request details.

### 2. Configure log output to a file

By default, logs go to the console (stdout). For production use, write logs to a file so you can search them later. Set N8N_LOG_OUTPUT to file and specify the file path with N8N_LOG_FILE_LOCATION. You can also set the output to both console and file by using a comma-separated value. Make sure the directory exists and n8n has write permissions.

```
# Log to a file
export N8N_LOG_OUTPUT=file
export N8N_LOG_FILE_LOCATION=/var/log/n8n/n8n.log

# Or log to both console and file
export N8N_LOG_OUTPUT=console,file
export N8N_LOG_FILE_LOCATION=/var/log/n8n/n8n.log

# Create the log directory
mkdir -p /var/log/n8n

n8n start
```

**Expected result:** n8n writes structured log entries to /var/log/n8n/n8n.log. Each entry includes a timestamp, log level, and message.

### 3. Configure logging in Docker

When running n8n in Docker, pass environment variables via the -e flag or a docker-compose.yml file. The Docker approach is the most common for production deployments. Mount a host directory for the log file so logs persist across container restarts.

```
# Docker run with logging
docker run -d \
  --name n8n \
  -p 5678:5678 \
  -e N8N_LOG_LEVEL=info \
  -e N8N_LOG_OUTPUT=console,file \
  -e N8N_LOG_FILE_LOCATION=/home/node/.n8n/logs/n8n.log \
  -v n8n_data:/home/node/.n8n \
  docker.n8n.io/n8nio/n8n
```

**Expected result:** The n8n container starts with info-level logging. Logs appear in docker logs output and are also written to the mounted volume.

### 4. Configure logging in docker-compose

For docker-compose setups, add the environment variables to your compose file. This is cleaner than passing multiple -e flags and makes your configuration version-controlled. Create a dedicated volume for logs so they survive container recreation.

```
# docker-compose.yml
version: '3.8'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - '5678:5678'
    environment:
      - N8N_LOG_LEVEL=info
      - N8N_LOG_OUTPUT=console,file
      - N8N_LOG_FILE_LOCATION=/home/node/.n8n/logs/n8n.log
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
```

**Expected result:** Running docker-compose up -d starts n8n with persistent file logging. Logs are stored inside the n8n_data volume.

### 5. Read and interpret log entries

Once logging is enabled, you need to know what to look for. n8n logs include the timestamp, level, component, and message. Look for ERROR entries to find failures, and INFO entries to trace execution flow. When debugging a specific workflow, search for the workflow ID or execution ID in the logs. The debug level includes HTTP request and response bodies, which is useful for diagnosing API errors.

```
# View the last 50 lines of the log file
tail -50 /var/log/n8n/n8n.log

# Follow logs in real time
tail -f /var/log/n8n/n8n.log

# Search for errors
grep 'ERROR' /var/log/n8n/n8n.log

# Search for a specific workflow execution
grep 'workflowId=123' /var/log/n8n/n8n.log
```

**Expected result:** You can see structured log entries with timestamps. ERROR lines highlight failures with stack traces. INFO lines show the execution flow for each workflow run.

## Complete code example

File: `docker-compose.yml`

```yaml
# docker-compose.yml — n8n with full logging configuration
version: '3.8'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    ports:
      - '5678:5678'
    environment:
      # Logging configuration
      - N8N_LOG_LEVEL=info
      - N8N_LOG_OUTPUT=console,file
      - N8N_LOG_FILE_LOCATION=/home/node/.n8n/logs/n8n.log
      # General configuration
      - N8N_HOST=0.0.0.0
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.example.com/
      # Database (optional — defaults to SQLite)
      - DB_TYPE=sqlite
      - DB_SQLITE_VACUUM_ON_STARTUP=true
    volumes:
      - n8n_data:/home/node/.n8n
    healthcheck:
      test: ['CMD', 'wget', '--spider', '-q', 'http://localhost:5678/healthz']
      interval: 30s
      timeout: 5s
      retries: 3

volumes:
  n8n_data:
    driver: local
```

## Common mistakes

- **Leaving N8N_LOG_LEVEL=debug in production permanently** — undefined Fix: Switch to info or warn after troubleshooting. Debug logs include sensitive data like API keys and request bodies.
- **Forgetting to create the log directory before starting n8n** — undefined Fix: Run mkdir -p /var/log/n8n (or the chosen path) and ensure the n8n user has write permissions.
- **Not restarting n8n after changing environment variables** — undefined Fix: n8n reads environment variables at startup. You must restart the process or container for changes to take effect.
- **Log file grows until the disk is full** — undefined Fix: Configure logrotate to rotate and compress logs daily. Example: /var/log/n8n/*.log { daily rotate 7 compress }.

## Best practices

- Use info level for production monitoring and debug only for active troubleshooting sessions
- Always configure file logging in production so you can review logs after an incident
- Set up log rotation with logrotate or a similar tool to prevent disk space exhaustion
- Include the workflow ID in your log searches to isolate issues to a specific workflow
- Switch back to warn or error level after debugging to reduce log noise and disk usage
- Mount log directories as persistent volumes in Docker so logs survive container restarts
- Use docker logs --tail 200 -f n8n for quick real-time debugging without file logging
- Combine n8n logs with a log aggregator like Loki or the ELK stack for searchable history

## Frequently asked questions

### What log levels does n8n support?

n8n supports four log levels: error (only errors), warn (errors and warnings), info (execution flow details), and debug (everything including HTTP bodies). Set the level with the N8N_LOG_LEVEL environment variable.

### Can I log to both the console and a file at the same time?

Yes. Set N8N_LOG_OUTPUT=console,file and provide a file path via N8N_LOG_FILE_LOCATION. n8n will write to both destinations simultaneously.

### Do I need to restart n8n after changing log settings?

Yes. n8n reads environment variables at startup only. After changing N8N_LOG_LEVEL or N8N_LOG_OUTPUT, restart the process or container for the new settings to take effect.

### Does debug logging expose sensitive data?

Yes. Debug-level logs can include API keys, request bodies, and credential details. Only use debug for active troubleshooting and switch back to info or warn afterward.

### How do I enable logging in n8n Cloud?

n8n Cloud does not expose server-level logging configuration. Use the Executions tab in the UI to inspect workflow runs. For full log access, use a self-hosted n8n deployment.

### Where does n8n write logs by default?

By default, n8n writes logs to the console (stdout) at the error level. No file logging is configured unless you set N8N_LOG_OUTPUT=file and provide N8N_LOG_FILE_LOCATION.

### Can RapidDev help me set up n8n logging and monitoring?

Yes. RapidDev can configure production-grade logging with log rotation, centralized aggregation, and alerting for your n8n deployment. Contact RapidDev for a free consultation.

---

Source: https://www.rapidevelopers.com/n8n-tutorial/how-to-enable-logging-in-n8n
© RapidDev — https://www.rapidevelopers.com/n8n-tutorial/how-to-enable-logging-in-n8n
