Title: Enable WooCommerce Debug Logging
Author: WordPress VIP Documentation
Published: June 4, 2021
Last modified: December 26, 2023

---

 1. [Plugins](https://docs.wpvip.com/plugins/)
 2. [WooCommerce](https://docs.wpvip.com/plugins/woocommerce/)
 3. Enable WooCommerce Debug Logging

#  Enable WooCommerce Debug Logging

WooCommerce provides [instructions to enable WooCommerce Debug Logging](https://docs.woocommerce.com/document/woocommerce-product-search/api/debugging/).
However, on VIP the WC Logger must be configured to write to the `WC_Log_Handler_DB`
handler to prevent debug logs from writing to the `/tmp` files directory. This WC
Logger handler should be defined in the [`vip-config.php` file](https://docs.wpvip.com/wordpress-skeleton/vip-config-directory/)
as seen in this example:

vip-config/vip-config.php

    ```lang-php
    define( 'WC_LOG_HANDLER', 'WC_Log_Handler_DB' );
    ```

By default, the WC Logger will retain logs for 30 days. Lowering the number of days
that logs are retained is recommended, and the `[woocommerce_logger_days_to_retain_logs](https://github.com/woocommerce/woocommerce/blob/ab4a46e32e338cbf33094ab26144744a021a21a9/includes/class-wc-logger.php#L294)`
[ filter](https://github.com/woocommerce/woocommerce/blob/ab4a46e32e338cbf33094ab26144744a021a21a9/includes/class-wc-logger.php#L294)
should be used to set a lower value. 

It is also recommended to disable WooCommerce debug logging once the needed configuration
and debugging for a project is complete. This will reduce unnecessary load on the
primary database.

Last updated: December 26, 2023