Skip to main content
Bitwarden Server uses Serilog for structured logging with support for file-based logging, console output, and various log levels. Proper logging configuration is essential for troubleshooting and monitoring.

Logging System Overview

The logging system is implemented in src/Core/Utilities/LoggerFactoryExtensions.cs and provides:
  • Structured JSON logging
  • File-based log rotation
  • Configurable log levels
  • Development vs. Production modes
  • ASP.NET Core integration

Configuration

File Logging Configuration

Bitwarden Server supports two configuration approaches for file logging: Add to your appsettings.json:

Legacy Configuration

Alternatively, configure under GlobalSettings:

Configuration Options

string
default:"/etc/bitwarden/logs/{Date}.txt"
Path template for log files. Use {Date} for daily rotation or a static filename for size-based rotation.
number
default:"null"
Maximum file size in bytes before rotation. If set, logs rotate by size instead of date. Recommended: 10485760 (10 MB).
boolean
default:"true"
When using legacy configuration, creates separate subdirectories for each project (Api, Identity, etc.).
number
default:"null"
Legacy option for size-based rotation in bytes.

Log Levels

Available Log Levels

Log Level Hierarchy:
  1. Trace - Most verbose, includes all details
  2. Debug - Debugging information
  3. Information - General operational messages
  4. Warning - Warning messages
  5. Error - Error messages
  6. Critical - Critical failures
  7. None - Logging disabled
Setting log levels to Trace or Debug in production can significantly impact performance and generate large log files. Use these levels only for troubleshooting specific issues.

Service-Specific Configuration

API Service

Default location: src/Api/appsettings.json

Identity Service

Default location: src/Identity/appsettings.json

Other Services

Each service (Admin, Events, Notifications, Icons, SSO, SCIM) supports the same logging configuration.

Log File Locations

Default Paths

Log Rotation

Daily Rotation (Default):
Size-Based Rotation:

Development vs. Production

Development Mode

File logging is automatically disabled in development environments (configured in LoggerFactoryExtensions.cs:20):
Development environments use console logging only.

Production Mode

Production deployments enable file logging with the configured settings. Logs are written to the specified directory.

Request Logging

Bitwarden Server includes request logging middleware (src/SharedWeb/Utilities/RequestLoggingMiddleware.cs) that logs:
  • Request method and path
  • Response status codes
  • Request duration
  • User context (if authenticated)
Enable in Startup:

Event Logging

Bitwarden uses a separate event logging system for audit events. See EventLogging configuration in GlobalSettings.
See Compliance and Audit Logging for details.

Log Management

Viewing Logs

1

Access Log Directory

Navigate to the configured log directory:
2

View Recent Logs

View the most recent log entries:
3

Search Logs

Search for specific patterns:

Log Retention

Implement a log retention policy to prevent disk space issues:
Schedule with cron:

Centralized Logging

For production environments, consider shipping logs to a centralized logging system: Fluentd/Fluent Bit:
Filebeat:

Troubleshooting Logging Issues

Logs Not Being Created

Check Permissions:
Verify Configuration:

Log Files Too Large

Enable Size-Based Rotation:
Reduce Log Level:

Best Practices

Use Appropriate Levels

Set Information for important operations, Warning for recoverable issues, Error for failures.

Rotate Regularly

Use daily rotation for high-volume services, size-based for lower volume.

Monitor Disk Space

Set up alerts when log directories exceed 80% capacity.

Centralize in Production

Ship logs to a centralized system for better analysis and retention.