Scriptbaker
SCRIPTBAKERAI & Software Engineering
Yii

Disabled Yii logs and stack trace messages

Learn how to enable and configure Yii debugging using YII_DEBUG and YII_TRACE_LEVEL. This guide explains how Yii debug settings work, how to view detailed error information, and why debugging should be disabled on production websites.

· 5 min read · By Tahir Yasin

If you are working with a Yii-based application and need to troubleshoot errors or understand what is happening behind the scenes, Yii's built-in debugging options can be very useful during development.

Enable Yii Debugging

Open the index.php file from your project's root folder and look for the following two lines:

defined('YII_DEBUG') or define('YII_DEBUG',true);defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

These settings enable Yii's debugging functionality and determine how much execution information is included in the application's error and trace output.

What Does YII_DEBUG Do?

YII_DEBUG is a Yii environment setting that enables additional debugging information. When debugging is enabled, developers can get more detailed error messages and diagnostic information, which makes it easier to identify problems during development.

For example, instead of seeing only a generic application error, developers may receive additional information about the file, line, exception, or component responsible for the problem.

What Does YII_TRACE_LEVEL Do?

YII_TRACE_LEVEL controls the level of call-stack information Yii provides when debugging. A higher trace level can provide more detailed information about how the application reached a particular point in the code.

This can be particularly helpful when debugging complex applications where a problem may involve multiple components, controllers, models, or framework calls.

Comment Out the Debugging Lines

If you want to disable these development debugging settings, you can comment out the lines:

// defined('YII_DEBUG') or define('YII_DEBUG',true);// defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

Important: Do Not Leave Detailed Debugging Enabled on Production

Debugging information is extremely useful during development, but exposing detailed error messages and stack traces on a live production website can reveal sensitive information about your application's structure, configuration, files, and code.

For this reason, debugging settings should be reviewed carefully before deploying a Yii application to production. Use detailed debugging primarily in controlled development or testing environments.

Why Yii Debugging Is Useful

Proper debugging can help developers:

  • Identify application errors more quickly
  • Trace problems back to the relevant part of the code
  • Understand application execution flow
  • Diagnose issues during development and testing
  • Reduce the time required to troubleshoot complex problems

Last updated:

Work with Scriptbaker

Let's talk about your project

Whether you're extending an existing platform, modernising legacy code, or planning something new, our engineers can help. Tell us what you're working on and we'll explore a practical technical solution together.