Enabling debug mode in Osclass helps administrators and developers diagnose issues related to PHP errors, database queries, and cache performance. Debug logs provide valuable insights that can assist in troubleshooting and optimizing performance. However, it is strongly recommended to disable debugging on production websites.
If your website displays an "Error 500" page, it likely means PHP errors are occurring in the background but are not visible. To enable debugging and view these errors, you need to modify the config.php
file in the root directory of your Osclass installation.
Add the following lines to enable PHP error display and logging:
ini_set('display_errors', 'on');
ini_set('log_errors', 'on');
ini_set('display_startup_errors', 'on');
ini_set('error_reporting', E_ALL);
To enable Osclass-specific debugging, add:
define('OSC_DEBUG', true);
This will display PHP errors, notices, and warnings directly on your website.
To store error logs in a file instead of displaying them publicly, enable logging by adding:
define('OSC_DEBUG_LOG', true);
This will save error logs to the oc-content/debug.log
file.
Osclass provides additional debugging options for specific components:
define('OSC_DEBUG_CACHE', true);
define('PHPMAILER_DEBUG_LEVEL', 2);
Accepted debug levels:
Database debugging in Osclass helps track database queries and performance. Enabling this mode may significantly affect performance, so it should only be used in development environments.
Add the following lines to config.php
to log database queries:
define('OSC_DEBUG_DB', true);
This will store all SQL queries in an array and display them at the bottom of the page.
To save database logs into a file, add:
define('OSC_DEBUG_DB_LOG', true);
The log file queries.log
will be created in the oc-content
folder. If your Apache server lacks write permissions, you may need to create the file manually and set the appropriate permissions (e.g., chmod 666 queries.log
).
To run EXPLAIN
queries and log their results, use:
define('OSC_DEBUG_DB_EXPLAIN', true);
This will save detailed query execution plans to explain_queries.log
in oc-content
. This setting is useful for optimizing slow queries.
Osclass provides a built-in debug log viewer in the backoffice. To access it, navigate to Tools > Debug/Error Log in the left sidebar. The left panel displays whether debug modes are enabled and provides instructions for enabling error logs. The right panel shows the contents of the debug.log
file, which stores PHP error logs when OSC_DEBUG_LOG
is enabled in config.php
.
OSC_DEBUG_LOG
to store errors instead of displaying them.OSC_DEBUG_DB
) can significantly slow down your website.By enabling and configuring these debug settings, you can efficiently diagnose and resolve issues in Osclass.