Answers.Body: <p>This is what we ended up using.</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      return [
          'components' =&gt; [
              'log' =&gt; [
                  'targets' =&gt; [
                      [
                          'class' =&gt; PsrTarget::class,
                          'logger' =&gt; $logger,
                          'levels' =&gt; [YiiLogger::LEVEL_ERROR],
                          'logVars' =&gt; [],
                          'addTimestampToContext' =&gt; true,
                      ],
                      // Split the targets to specifically exclude classes which spam the logs, while
                      // ensuring errors thrown in those classes are still logged.
                      [
                          'class' =&gt; PsrTarget::class,
                          'logger' =&gt; $logger,
                          'levels' =&gt; $logLevels,
                          'except' =&gt; [
                              'yii\base\View::renderFile',
                              'yii\db\Command::*',
                              'yii\db\Connection::*'
                          ],
                          'logVars' =&gt; [],
                          'addTimestampToContext' =&gt; true,
                      ],
                  ],
              ],
          ],
      ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-03T09:25:12.933Z
Answers.LastActivityDate: 2020-03-03T09:25:12.933Z
Answers.UserDisplayName: Aaron Cimolini
Answers.Body: <p>You can extend the default database component (including the Connection class) via <code>config/app.php</code> like so: <a href="https://docs.craftcms.com/v3/config/app.html#database-component" rel="nofollow noreferrer">https://docs.craftcms.com/v3/config/app.html#database-component</a></p>
  
  <p>In your case, it should just be:</p>
  
  <pre><code>&lt;?php
  return [
      'components' =&gt; [
          'redis' =&gt; [
              'class' =&gt; craft\db\Connection::class,
              'enableLogging' =&gt; false
          ],
      ],
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-03T09:22:32.963Z
Answers.Text: Thanks for the help but it didn't end up working for us.
Answers.UserDisplayName: Aaron Cimolini
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-25T23:09:17.657Z
Answers.LastActivityDate: 2020-02-25T23:09:17.657Z
Answers.UserDisplayName: Brad Bell
Body: <p>We're currently logging our site at LEVEL_INFO to have a good idea of what's happening on the site. We find it useful, and appropriate, to log informational messages at that level rather than at ERROR or WARNING. However most of these INFO messages are drowned out by the sheer volume of SQL query logging. I did some digging and found that Yii DB Connections can be configured to not log all the queries.</p>
  
  <p><a href="https://github.com/yiisoft/yii2/blob/ec089fea5a684de1e358995bf36522ec6834e71b/framework/db/Connection.php#L410" rel="nofollow noreferrer">https://github.com/yiisoft/yii2/blob/ec089fea5a684de1e358995bf36522ec6834e71b/framework/db/Connection.php#L410</a></p>
  
  <p>This setting is then checked here:
  <a href="https://github.com/yiisoft/yii2/blob/bdb7c6491061b48c16b0fdbcba791ccd514a91d9/framework/db/Command.php#L1112" rel="nofollow noreferrer">https://github.com/yiisoft/yii2/blob/bdb7c6491061b48c16b0fdbcba791ccd514a91d9/framework/db/Command.php#L1112</a></p>
  
  <p>Ideally we'd like to be able to log queries at the TRACE or DEBUG level but it doesn't look to be possible.</p>
  
  <p>Is there a simple way to disable the logging in the craft config? If not Would it be possible by extending an existing Craft class?</p>
  
  <p>Any pointers or help would be appreciated. Thanks in advance!</p>
  
Tags: <craft3><php><yii><logs><logging>
Title: Is it possible to allow logging at LEVEL_INFO without logging all the SQL queries?
ThreadText: # Is it possible to allow logging at LEVEL_INFO without logging all the SQL queries?
  
  (Asked by: username_0 on 2020-02-25)
  
  We're currently logging our site at LEVEL\_INFO to have a good idea of what's happening on the site. We find it useful, and appropriate, to log informational messages at that level rather than at ERROR or WARNING. However most of these INFO messages are drowned out by the sheer volume of SQL query logging. I did some digging and found that Yii DB Connections can be configured to not log all the queries.
  
  <https://github.com/yiisoft/yii2/blob/ec089fea5a684de1e358995bf36522ec6834e71b/framework/db/Connection.php#L410>
  
  This setting is then checked here:
  <https://github.com/yiisoft/yii2/blob/bdb7c6491061b48c16b0fdbcba791ccd514a91d9/framework/db/Command.php#L1112>
  
  Ideally we'd like to be able to log queries at the TRACE or DEBUG level but it doesn't look to be possible.
  
  Is there a simple way to disable the logging in the craft config? If not Would it be possible by extending an existing Craft class?
  
  Any pointers or help would be appreciated. Thanks in advance!
  
  **Tags:** craft3, php, yii, logs, logging
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-03-03. Score: 1 | Accepted answer
  
  This is what we ended up using.
  
  ```php
  <?php
      return [
          'components' => [
              'log' => [
                  'targets' => [
                      [
                          'class' => PsrTarget::class,
                          'logger' => $logger,
                          'levels' => [YiiLogger::LEVEL_ERROR],
                          'logVars' => [],
                          'addTimestampToContext' => true,
                      ],
                      // Split the targets to specifically exclude classes which spam the logs, while
                      // ensuring errors thrown in those classes are still logged.
                      [
                          'class' => PsrTarget::class,
                          'logger' => $logger,
                          'levels' => $logLevels,
                          'except' => [
                              'yii\base\View::renderFile',
                              'yii\db\Command::*',
                              'yii\db\Connection::*'
                          ],
                          'logVars' => [],
                          'addTimestampToContext' => true,
                      ],
                  ],
              ],
          ],
      ];
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2020-02-25. Score: 0
  
  You can extend the default database component (including the Connection class) via `config/app.php` like so: <https://docs.craftcms.com/v3/config/app.html#database-component>
  
  In your case, it should just be:
  
  ```
  <?php
  return [
      'components' => [
          'redis' => [
              'class' => craft\db\Connection::class,
              'enableLogging' => false
          ],
      ],
  ];
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the help but it didn't end up working for us.  
  
  ---
  
  