Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Debugging

How to Enable Debug Mode in MediaWiki Safely

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable MediaWiki debugging in LocalSettings.php, reproduce the problem in a private or staging wiki, collect the smallest useful diagnostic, and then turn the setting off. The usual starting point is $wgShowExceptionDetails = true; for a PHP exception or $wgDebugLogFile for persistent server-side logging. Use ?debug=true in the page URL when the failure is in ResourceLoader JavaScript rather than PHP.

What MediaWiki debug mode actually means

MediaWiki does not have one master switch named “debug mode.” Its principal diagnostics are independent configuration variables, and they are disabled by default. You choose the output that matches the failure: a stack trace for an uncaught exception, a profiling and logging toolbar, raw messages rendered at the bottom of a page, development notices, a server-side file, or browser-side ResourceLoader output.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Most server-side switches are set in the wiki’s LocalSettings.php. The web server must be able to read the file, and PHP must be able to write any destination you configure. Make changes in a private or staging copy first; public diagnostic output can reveal implementation details and user-submitted data.

Choose the smallest diagnostic that answers your question

Diagnostic Where you see it What it adds Best use Exposure and operational cost
$wgShowExceptionDetails Error response Detailed stack trace for an uncaught exception, including function parameter information when available One reproducible PHP failure High information exposure; enable briefly and only in a controlled environment
$wgDebugToolbar Page toolbar Profiling information and collected log messages Requests that complete but behave unexpectedly Visible diagnostic data and additional page overhead
$wgShowDebug Bottom of the rendered page Raw log messages for the current request Quickly checking what a request emitted Can expose internal and request data to anyone who can view the page
$wgDevelopmentWarnings PHP warnings and logs Notices for possible errors and deprecated functions Extension or upgrade compatibility work May be noisy; unsuitable for a public production response
$wgDebugLogFile Server-side file Persistent diagnostics across requests Intermittent failures and background jobs Consumes disk space and must be kept outside the public web root
?debug=true Browser developer tools Unminified or development-oriented ResourceLoader behavior and client-side messages JavaScript delivery, module, and browser errors URL-scoped client diagnostics; it does not enable PHP logging
XDebug PHP debugger Breakpoints, call-stack inspection, variable watches, and step-through execution Code paths that cannot be understood from logs Requires server and IDE setup; use on development systems

Prepare before changing LocalSettings.php

  1. Reproduce privately. Use a staging wiki, an access-restricted maintenance window, or a local copy. Do not begin by exposing diagnostics on an open public wiki.
  2. Back up the configuration. Save the current LocalSettings.php and note which lines you add. A syntax error in this file can prevent MediaWiki from loading.
  3. Identify the request type. A PHP exception, a warning during an upgrade, a slow request, and a browser-only JavaScript failure need different instruments. Selecting one setting first keeps the output understandable.
  4. Check the account and paths. The PHP or web-server account must be able to create and write a log file. The destination should be on a filesystem with enough free space and must not be served as a downloadable web asset.
  5. Capture a baseline. Record the MediaWiki version, PHP version, enabled extensions, the failing URL, the time of reproduction, and the exact action that triggers the fault. These details let you correlate a page error with the corresponding log entry.

Enable exception details for a PHP failure

Set the boolean variable in LocalSettings.php:

$wgShowExceptionDetails = true;

With this value set to true, an uncaught exception displays a detailed stack trace instead of only a generic error. The trace can identify the extension, class, file, and line that failed, and function parameter information may be exposed as well.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

A controlled reproduction

  1. Edit LocalSettings.php with the same account and deployment method used for your normal configuration changes.
  2. Save the file and load the failing page in a private browser session.
  3. Record the exception type, message, stack frames, and timestamp. Copy only what is needed to diagnose the fault.
  4. Restore $wgShowExceptionDetails to false (or remove the line) immediately after the reproduction.

If the page still shows only a generic error, verify that the edited file is the one used by the running wiki, clear any configuration cache used by your deployment, and check the web-server error log. Do not assume a missing stack trace means the failure disappeared; it can indicate that the request is being handled by another server, container, or PHP pool.

Add request diagnostics with the toolbar or page output

Debug toolbar

Add:

$wgDebugToolbar = true;

The toolbar adds profiling information and log messages to completed pages. It is useful when a request succeeds but is slow, performs an unexpected query, or emits messages that do not appear in the normal interface. Because the toolbar is rendered into the response, restrict access to the people conducting the investigation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Raw messages at the bottom of the page

Add:

$wgShowDebug = true;

This places raw log messages at the bottom of the page for the request. It is a fast way to confirm whether a hook, extension, or request path emitted a message, but it is also the easiest setting to expose to ordinary visitors. Use it only while access is controlled, then disable it.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Development warnings

Add:

$wgDevelopmentWarnings = true;

MediaWiki then reports notices for possible errors and deprecated functions. This is valuable during extension development and version upgrades, when a deprecation warning can identify code that will fail later. Expect more output than with a single exception, so enable it for a focused test rather than leaving it on indefinitely.

Write diagnostics to a persistent server-side file

For failures that are intermittent, occur in maintenance scripts, or disappear before you can read a page, configure a file:

$wgDebugLogFile = "/var/log/mediawiki/debug-{$wgDBname}.log";

The example creates a database-name-specific file under /var/log/mediawiki. Choose a directory appropriate to your operating system, keep it outside the public web root, and apply permissions that allow the PHP or web-server account to create and append to the file while preventing ordinary users from reading it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Verify write access without weakening permissions

  1. Create the parent directory as an administrator if it does not already exist.
  2. Assign ownership or group membership so the account running MediaWiki can write there.
  3. Use the least-permissive mode that still permits appending; do not make the directory world-writable.
  4. Trigger one known request and confirm that the file’s modification time and size change.
  5. Read the file through a privileged administrative path, not through a URL.

A debug log can contain login credentials, session cookies, submitted form values, and other private data. Treat it like a credential-bearing production artifact: restrict access, encrypt backups, and remove copies that are no longer needed. The file can also grow quickly, so monitor disk usage and configure your operating system’s log rotation or a scheduled retention policy. Rotation should preserve the permissions of newly created files and should not leave old copies in a web-served directory.

Separate noisy components into grouped logs

When one large file is difficult to analyze, MediaWiki’s grouped logging configuration can route channels such as exceptions or ResourceLoader messages to separate destinations through $wgDebugLogGroups. The exact channel names and logger behavior depend on the MediaWiki version and on whether the default logger has been replaced. Consult the logger documentation for the version installed on your wiki before adding group definitions, then test each route with a request that is known to emit that channel.

Debug ResourceLoader and browser JavaScript

If pages render but JavaScript is missing, stale, concatenated unexpectedly, or failing in the browser, append ?debug=true to the page URL, for example:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
https://wiki.example.test/Main_Page?debug=true

This is a URL-level client-side switch. Open the browser’s developer tools and inspect both the Console and Network panels:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Console: note the first exception, source file, line number, and module name. Later errors may be consequences of the first one.
  • Network: look for failed JavaScript requests, non-success HTTP status codes, redirects to login, incorrect MIME types, and responses that contain HTML instead of JavaScript.
  • Request parameters: compare a normal request with the debug=true request to see whether a module is missing, reordered, or served from an unexpected host.
  • Cache behavior: test in a private window or clear the browser cache after correcting a module, so an old ResourceLoader response does not mask the change.

?debug=true does not enable server-side exception details, page logging, or file logging. If the browser reports an HTTP 500 response, use the server-side settings in addition to the browser tools; if the response is successful but a module throws, keep the investigation in the browser first.

Use XDebug when logs cannot explain the code path

XDebug provides interactive, step-by-step PHP debugging. It is appropriate when you need to stop at a hook, inspect changing variables, follow a call stack, or determine why a conditional branch is taken. MediaWiki’s debugging guidance includes examples for MediaWiki-Vagrant and command-line maintenance scripts, but the installation and connection steps vary by operating system, PHP version, web server, container, and IDE.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

A safe step-through workflow

  1. Install and enable XDebug only on a development or staging PHP runtime.
  2. Configure the IDE and PHP runtime to agree on the debugging port, path mappings, and trigger mode.
  3. Set a breakpoint in the extension, hook, or core method suspected of handling the request.
  4. Start the IDE listener, trigger one request, and step over or into the relevant calls while watching arguments and return values.
  5. Detach the debugger and disable the remote trigger when the investigation ends. A debugger attached to a public production endpoint can expose source code and request data.

For command-line maintenance scripts, launch the script with the debugger trigger enabled in the shell environment and attach the IDE before execution reaches the breakpoint. For web requests, ensure the IDE’s path mapping points to the same source tree that PHP executes; otherwise breakpoints may appear set but never bind.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A practical troubleshooting sequence

  1. Classify the symptom. Decide whether it is an uncaught PHP exception, a warning or deprecation, missing server logs, a browser-only JavaScript failure, or code that requires stepping through.
  2. Start with one instrument. Use $wgShowExceptionDetails for a reproducible exception, $wgDebugLogFile for persistent evidence, or ?debug=true for ResourceLoader output. Add toolbar or raw page output only if the first instrument does not answer the question.
  3. Reproduce once and timestamp it. Note the exact URL or maintenance command, account, action, and UTC or server-local time. This makes it possible to find the matching log entry among concurrent requests.
  4. Check the execution layer. A blank page, proxy error, or HTTP 500 may be generated by the web server or PHP before MediaWiki can render its diagnostics. Inspect those service logs and confirm that the request reached the expected wiki instance.
  5. Validate logging permissions. If no file appears, test the parent directory, ownership, mandatory access controls, filesystem capacity, and the identity of the PHP worker. Do not solve a permission problem by granting unrestricted write access.
  6. Follow the evidence. Use the first meaningful exception or browser error, then inspect the referenced extension, configuration value, hook, or request. Treat later cascading errors as secondary until the first fault is understood.
  7. Escalate to XDebug. If messages identify a broad code path but not the incorrect state, reproduce on staging with a breakpoint and inspect the values at the decision point.
  8. Clean up. Disable temporary display settings, secure or delete diagnostic files, rotate any exposed credentials, and verify from an unauthenticated browser that visitors no longer see debug output.

Common failure modes and fixes

Symptom Likely cause Corrective action
The page remains generic after enabling exception details The edited configuration is not loaded, or the error occurs before MediaWiki handles the request Confirm the active wiki and PHP pool, check syntax and web-server/PHP logs, and verify the setting is placed in the loaded LocalSettings.php.
No debug log file is created Parent directory is absent or unwritable, the path is invalid, or the request uses another server/container Create the directory, grant narrowly scoped write access to the PHP account, test free space, and trigger a request on the instance that owns the path.
The log exists but grows unexpectedly fast Verbose settings or a repeated failing request are generating messages continuously Disable unnecessary output, stop the failing loop, rotate the file, and check disk usage before reproducing again.
Visitors can see a toolbar or messages Display-oriented settings were left enabled on a public route Set the display switches back to their defaults, purge any cached response, and test while logged out.
?debug=true shows no useful difference The problem is server-side, the URL parameter was not sent to the failing request, or the browser is displaying cached assets Inspect the actual Network requests, retry in a private window, and pair browser tools with server logging if the response is an HTTP or PHP failure.
A breakpoint never binds IDE path mapping, PHP runtime, or XDebug trigger configuration does not match Confirm the executed source path, debugger port, trigger mode, and IDE mapping on the staging runtime.
Logs contain secrets Request data or authentication details were recorded during diagnosis Restrict the file, remove public copies, redact before sharing, and rotate credentials or invalidate sessions that may have been exposed.

Security checklist before returning the wiki to normal

  • Set $wgShowExceptionDetails, $wgDebugToolbar, $wgShowDebug, and $wgDevelopmentWarnings back to disabled values unless a documented, access-controlled maintenance task still requires one.
  • Move $wgDebugLogFile outside the web root and verify that a direct HTTP request cannot download it.
  • Apply ownership and permissions appropriate to the PHP account, and confirm rotated files inherit the same protection.
  • Search diagnostic output for cookies, passwords, tokens, form values, and personal data before sending excerpts to another person.
  • Delete or securely archive logs after the retention period, and monitor the filesystem while verbose logging is active.
  • Disable XDebug triggers and remote debugging on any endpoint that is reachable from the public internet.
  • Test the wiki as an anonymous visitor and as a normal user to ensure no stack trace, toolbar, raw message, or source-map detail is exposed.

Minimal configuration examples

Short exception investigation

$wgShowExceptionDetails = true;

Use this for one controlled reproduction, record the trace, and then remove or disable it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Persistent logging without page disclosure

$wgDebugLogFile = "/var/log/mediawiki/debug-{$wgDBname}.log";

This keeps messages on the server instead of adding them to visitor-facing HTML. The path still requires protected permissions, free space, and rotation.

Broader development diagnostics

$wgDebugToolbar = true;
$wgShowDebug = true;
$wgDevelopmentWarnings = true;

Enable this combination only when the additional output is justified and access to the wiki is controlled. Narrow the configuration again as soon as the relevant evidence is collected.

Which method should you use?

For a single, reproducible fatal error, start with exception details on staging. For an intermittent request, scheduled job, or failure that cannot be displayed safely, use a protected debug log file. For a completed page that is unexpectedly slow or noisy, the toolbar gives request-level context; raw page output is a quicker but more exposed alternative. For a browser-only failure, use ?debug=true and the Console and Network panels. When those traces identify the area but not the cause, move to XDebug on a non-public development runtime.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DebuggingLocalSettings.phpMediaWikiPHPResourceLoaderXdebug

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.