Make WP_DEBUG log to custom file
- Force WordPress to log errors to a custom file location
- Use WP_DEBUG_LOG constant in wp-config.php file
WordPress is one of the world’s most popular content management systems and – fortunately – it comes equipped with a built-in debugging functionality. However, the option is not available from the admin panel and you have to do some file editing to make it work. When debugging WordPress the WP_DEBUG option can be really helpful. You can see error 500 message details or deprecated methods from an old PHP version.
WP Debug Configuration
To show debug details directly on the website, add / edit this line in your wp-config.php file:
To log messages to file /wp-content/debug.log (standard location)
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 );
To log a message to a custom file:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', 'wp-content/my_debug_file987.log' ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 );
Using a custom debug file name is recommended due to security measures. After finishing debugging, remember to disable WP_DEBUG and delete .log files from the server.
Need a more powerful debug tool? Query Monitor is a plugin that enables debugging of database queries, PHP errors, hooks and actions, More info at: https://wordpress.org/plugins/query-monitor/
About the article Author:
Techleader of createIT, working in the IT sector for over 14 years. Innovator, author, and owner of an e-shop that he has been continuously developing for over 10 years. Currently, with his team of over 20 developers, he supervises all kinds of e-commerce projects of varied structure, characteristics, and size: from simple on-line shops for retail clients to advanced B2B platforms with support of multiple shopping carts, multiple languages, and integration with external systems. His work also involves modifying and expanding the existing platforms with millions of products in their databases, platforms that support variable pricing (several variants of the same product), dropshipping modules, integration with storage systems, integration with courier delivery services, and the last but not least, the optimization of scripts. By participating in a multitude of projects, he had the opportunity to “test out” all kinds of platforms (open-source, SaaS – Cloud-Hosted eCommerce Platforms) and dedicated platforms.
Hi, we are createIT!
As a passionate group of professionals with a love for Web and mobile technologies, we have been successfully serving our clients for the past 15 years. Through these years we have continuously striven to create the best IT solutions our clients seek.
Our 70+ developer team creates cutting-edge complex B2B and B2C web systems and apps as well as delivers top-notch direct outsourcing services.
We are located in Warsaw, Poland, in the heart of Europe. Concentrated on delivering durable web solutions of high integrity, we do not always try to be the cheapest. However, thanks to our location you will be surprised how reasonable our prices are.
Fluent in English we offer services worldwide. Among others, in countries such as the U.S.A., Great Britain, Germany, Australia, Sweden and Poland.