Logging System Overview
The logging system is implemented insrc/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:Modern Configuration (Recommended)
Add to yourappsettings.json:
Legacy Configuration
Alternatively, configure underGlobalSettings:
Configuration Options
Path template for log files. Use
{Date} for daily rotation or a static filename for size-based rotation.Maximum file size in bytes before rotation. If set, logs rotate by size instead of date. Recommended:
10485760 (10 MB).When using legacy configuration, creates separate subdirectories for each project (Api, Identity, etc.).
Legacy option for size-based rotation in bytes.
Log Levels
Available Log Levels
Trace- Most verbose, includes all detailsDebug- Debugging informationInformation- General operational messagesWarning- Warning messagesError- Error messagesCritical- Critical failuresNone- Logging disabled
Recommended Production Levels
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
| Service | Default Path |
|---|---|
| API | /etc/bitwarden/logs/Api/{Date}.txt |
| Identity | /etc/bitwarden/logs/Identity/{Date}.txt |
| Admin | /etc/bitwarden/logs/Admin/{Date}.txt |
| Events | /etc/bitwarden/logs/Events/{Date}.txt |
| Notifications | /etc/bitwarden/logs/Notifications/{Date}.txt |
| Icons | /etc/bitwarden/logs/Icons/{Date}.txt |
| SSO | /etc/bitwarden/logs/Sso/{Date}.txt |
| SCIM | /etc/bitwarden/logs/Scim/{Date}.txt |
Log Rotation
Daily Rotation (Default):Development vs. Production
Development Mode
File logging is automatically disabled in development environments (configured inLoggerFactoryExtensions.cs:20):
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)
Event Logging
Bitwarden uses a separate event logging system for audit events. SeeEventLogging configuration in GlobalSettings.
Log Management
Viewing Logs
Log Retention
Implement a log retention policy to prevent disk space issues:Centralized Logging
For production environments, consider shipping logs to a centralized logging system: Fluentd/Fluent Bit:Troubleshooting Logging Issues
Logs Not Being Created
Check Permissions:Log Files Too Large
Enable Size-Based Rotation: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.