Logging System
- Logging System
This article details the logging system used on our MediaWiki installation. Proper logging is crucial for troubleshooting, security auditing, and performance monitoring. This guide is intended for newcomers to the server administration aspects of the wiki.
Overview
Our MediaWiki instance utilizes a tiered logging approach. We primarily leverage the built-in PHP logging mechanisms, coupled with system-level logging via `syslog` and file rotation. This combination provides a robust and flexible system for capturing a wide range of events. Understanding the configuration options is essential for effective maintenance and diagnostics. We also utilize Special:Log for user-centric logs, but this article focuses on the underlying server-side logging. Proper configuration of logging avoids filling up disk space, and allows for quick diagnosis of issues. Refer to the Manual:Logging page for a broader overview of logging within MediaWiki.
PHP Logging Configuration
MediaWiki's core logging is configured through the `$wgDebugLogGroups` and `$wgDebugLogFile` variables in `LocalSettings.php`. These settings control which debugging messages are recorded and where they are stored.
The `$wgDebugLogGroups` array defines the types of debugging messages to capture. Common groups include:
- `suppress`: Suppressed errors (errors that don't halt execution).
- `notice`: Non-critical messages.
- `warn`: Warning messages.
- `error`: Errors that do not halt execution.
- `fatal`: Fatal errors that halt execution.
- `exception`: Uncaught exceptions.
The `$wgDebugLogFile` variable specifies the file path where the debug log is written. It's vital to ensure this file is writable by the web server user (typically `www-data` or `apache`).
Here's a table summarizing the key PHP logging configuration options:
Configuration Option | Description | Example Value |
---|---|---|
`$wgDebugLogGroups` | Array of debug message types to log. | `array( 'suppress', 'warn', 'error', 'fatal', 'exception' )` |
`$wgDebugLogFile` | Path to the debug log file. | `/var/log/mediawiki/debug.log` |
`$wgShowDebugDetails` | Displays detailed debug information on error pages (development only!). | `true` or `false` |
`$wgEnableCacheDirectory` | Enables logging of cache-related events. | `true` or `false` |
It is *strongly* recommended that `$wgShowDebugDetails` be set to `false` in a production environment for security reasons. Detailed error information can reveal sensitive server details. See Configuration Settings for a complete list of settings.
System Logging (Syslog)
MediaWiki can be configured to send logs to the system's `syslog` facility. This allows for centralized log management and integration with other system monitoring tools. Configuration is done via the `$wgSyslogIdentity` and `$wgSyslogFacility` variables in `LocalSettings.php`.
- `$wgSyslogIdentity`: A string identifying the source of the log messages (e.g., "mediawiki").
- `$wgSyslogFacility`: The syslog facility to use (e.g., `LOG_LOCAL0`).
Syslog provides benefits like standardized log formats and integration with log aggregation tools like rsyslog or syslog-ng. See Syslog for more information on this technology.
Configuration Option | Description | Example Value |
---|---|---|
`$wgSyslogIdentity` | Identifies the source of syslog messages. | `mediawiki` |
`$wgSyslogFacility` | Syslog facility to use. | `LOG_LOCAL0` |
`$wgSyslogEnabled` | Enables or disables syslog logging. | `true` or `false` |
Log Rotation
Log files can grow rapidly, consuming significant disk space. To prevent this, we utilize log rotation. `logrotate` is a standard system utility for managing log files. A configuration file for MediaWiki logs is located at `/etc/logrotate.d/mediawiki`.
Here's a sample `/etc/logrotate.d/mediawiki` configuration:
``` /var/log/mediawiki/*.log {
daily rotate 7 missingok notifempty compress delaycompress sharedscripts postrotate /usr/bin/kill -USR1 `cat /var/run/mediawiki-php-fpm.pid 2>/dev/null` > /dev/null 2>&1 || true endscript
} ```
This configuration rotates logs daily, keeps 7 days' worth of logs, compresses older logs, and sends a `USR1` signal to the PHP-FPM process to reopen log files after rotation. Refer to Log Rotation for details on configuring `logrotate`.
Logrotate Parameter | Description |
---|---|
`daily` | Rotate logs daily. |
`rotate 7` | Keep 7 rotated log files. |
`missingok` | Don't error if the log file is missing. |
`notifempty` | Don't rotate if the log file is empty. |
`compress` | Compress rotated log files. |
`delaycompress` | Delay compression until the next rotation cycle. |
`sharedscripts` | Run the `postrotate` script only once for all rotated logs. |
`postrotate` | Script to run after rotation. |
Important Log Files
The following table lists the most important log files to check when troubleshooting:
Log File | Description |
---|---|
`/var/log/mediawiki/debug.log` | PHP debugging messages as configured by `$wgDebugLogGroups`. |
`/var/log/apache2/error.log` (or equivalent) | Apache web server error log. |
`/var/log/syslog` (or equivalent) | System log (contains MediaWiki messages if syslog is configured). |
`/var/log/mediawiki/error.log` | Errors specifically related to MediaWiki. |
Further Reading
- Manual:Logging - Official MediaWiki documentation on logging
- Configuration Settings - A complete list of MediaWiki configuration settings.
- Syslog - Information about the syslog protocol.
- Log Rotation - Details about configuring log rotation.
- Special:Log - Accessing user-centric logs within the wiki itself.
Intel-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Core i7-6700K/7700 Server | 64 GB DDR4, NVMe SSD 2 x 512 GB | CPU Benchmark: 8046 |
Core i7-8700 Server | 64 GB DDR4, NVMe SSD 2x1 TB | CPU Benchmark: 13124 |
Core i9-9900K Server | 128 GB DDR4, NVMe SSD 2 x 1 TB | CPU Benchmark: 49969 |
Core i9-13900 Server (64GB) | 64 GB RAM, 2x2 TB NVMe SSD | |
Core i9-13900 Server (128GB) | 128 GB RAM, 2x2 TB NVMe SSD | |
Core i5-13500 Server (64GB) | 64 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Server (128GB) | 128 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Workstation | 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000 |
AMD-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Ryzen 5 3600 Server | 64 GB RAM, 2x480 GB NVMe | CPU Benchmark: 17849 |
Ryzen 7 7700 Server | 64 GB DDR5 RAM, 2x1 TB NVMe | CPU Benchmark: 35224 |
Ryzen 9 5950X Server | 128 GB RAM, 2x4 TB NVMe | CPU Benchmark: 46045 |
Ryzen 9 7950X Server | 128 GB DDR5 ECC, 2x2 TB NVMe | CPU Benchmark: 63561 |
EPYC 7502P Server (128GB/1TB) | 128 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/2TB) | 128 GB RAM, 2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/4TB) | 128 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/1TB) | 256 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/4TB) | 256 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 9454P Server | 256 GB RAM, 2x2 TB NVMe |
Order Your Dedicated Server
Configure and order your ideal server configuration
Need Assistance?
- Telegram: @powervps Servers at a discounted price
⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️