Answers.Body: <p>As someone who theoretically might inherit your site one day... and also as future-you trying to diagnose a problem... please don't try to limit what Craft logs. If you want a quicker way to look for critical problems, check out the Yii2 Debug Toolbar as discussed here <a href="https://nystudio107.com/blog/profiling-your-website-with-craft-cms-3s-debug-toolbar" rel="nofollow noreferrer">Profiling your Website with Craft CMS 3’s Debug Toolbar</a></p>
  <p>You can use it to very quickly and easily see only errors, or only warnings, and so on. And then if the additional data that Craft logs is needed to help you diagnose a problem, it'll still be there.</p>
  <p>To learn how to parse the Craft CMS log files quickly, check out the <a href="https://nystudio107.com/blog/zen-and-the-art-of-craft-cms-log-file-reading" rel="nofollow noreferrer">Zen and the Art of Craft CMS Log File Reading</a></p>
  <p>If you do end up wanting to make your own logger, check out the <a href="https://nystudio107.com/blog/creating-a-custom-logger-for-craft-cms" rel="nofollow noreferrer">Creating a Custom Logger for Craft CMS</a> article</p>
  <p>I echo Brad's comments, though, unless for some reason <code>devMode</code> is on, it shouldn't be logging every query, except for performance profiling.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-27T04:04:37.910Z
Answers.LastActivityDate: 2020-07-16T12:06:35.587Z
Answers.LastEditDate: 2020-07-16T12:06:35.587Z
Answers.UserDisplayName: andrew.welch
Answers.Body: <p>This will be a similar answer as here: <a href="https://craftcms.stackexchange.com/questions/28109/craft-3-large-log-file-sizes/28145#28145">Craft 3 large log file sizes</a></p>
  
  <p>Basically Craft goes with Yii's default <code>FileTarget</code> settings, which is 5 log files of 10MB each before they start rotating out.  Those are individual limits for both <code>web.log</code> and <code>console.log</code> files.</p>
  
  <p>If you want to change those behaviors you'll need to modify those properties via a <code>config/app.php</code> file using your own FileTarget settings.</p>
  
  <p>There's another post here with some useful guidance: <a href="https://craftcms.stackexchange.com/questions/25427/craft-3-plugins-logging-in-a-separate-log-file/25430#25430">Craft 3 plugins - Logging in a separate *.log file</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-28T02:27:04.260Z
Answers.LastActivityDate: 2018-10-28T02:27:04.260Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>We were having the same issue.  Our logs were getting so dense with SQL statements that it was hard to find our errors.  And for the most part, seeing Craft's internal SQL would not help us debug the problem.</p>
  <p>What we've found is we can use the <a href="https://github.com/onedesign/onelogger" rel="nofollow noreferrer">onelogger plugin</a>.  After installing it, we just needed to add a file called onelogger.php to our config file.  This is what we used:</p>
  <pre><code>&lt;?php
  
  return [
    'logLevels' =&gt; getenv('ONELOGGER_LOG_LEVELS') ? explode(',', getenv('ONELOGGER_LOG_LEVELS')) : ['warning', 'error']
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-13T20:12:58.403Z
Answers.LastActivityDate: 2020-07-13T20:12:58.403Z
Answers.UserDisplayName: Francis McGrath
Answers.Body: <p>Even so this thread is old, maybe my answer can help someone:
  <a href="https://craftcms.stackexchange.com/questions/35907/cleanup-craft-logs">Cleanup Craft Logs</a></p>
  <p><strong>Basically it's possible via app.php</strong> to remove all unnecessary logs such as all the $_GET, $_POST, $_SERVER variables and all the SQL being logged.</p>
  <p>The main point you need is to configure in <strong>app.php</strong> the log component. The entry <strong>'logVars'</strong> will get rid of all the $_SERVER values logged (also fixed security issues with password appearing in the logs).
  The other interesting configuration is the <strong>'except'</strong> array where we excluded a few classes. 'yii\db\Connection::*' for example removes all SQL logs.</p>
  <pre><code>return [
      'modules' =&gt; [
          'mymodule' =&gt; MyModule::class,
          // My modules mapped here
      ],
      'components' =&gt; [
          'log' =&gt; function() {
              return Craft::createObject([
                  'class' =&gt; yii\log\Dispatcher::class,
                  'targets' =&gt; [
                      [
                          'class' =&gt; codemix\streamlog\Target::class,
                          'url' =&gt; 'php://stderr',
                          'levels' =&gt; Craft::$app-&gt;getConfig()-&gt;general-&gt;devMode ?
                              (yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING | yii\log\Logger::LEVEL_INFO) :
                              (yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING),
                          'except' =&gt; [
                              'yii\base\View::renderFile',
                              'yii\db\Command::*',
                              'yii\db\Connection::*' // We don't want sql to be logged
                          ],
                          // don't log global variables like $_SERVER etc periodically in logs.
                          // See: yii\log\Target::class, collect method usually appends getContextMessage
                          'logVars' =&gt; []
                      ]
                  ]
              ]);
          }
      ],
      'bootstrap' =&gt; [
          // My module names here
      ],
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-27T11:25:43.030Z
Answers.LastActivityDate: 2021-04-27T11:25:43.030Z
Answers.UserDisplayName: judos
Body: <p>I've got a Craft CMS installation that is set to production mode. I notice that my logs get flooded with a bunch of entries which don't seem very useful.</p>
  
  <p>For example, in a matter of several days, I've already got <code>console.log</code> up to <code>console.log.5</code> - So it's rotated the log file 5 times already. These files are filled with what seems like every single query that gets executed on the website. They're 70k lines a piece. It also logs a lot of entries in <code>queue.log</code>, among other files.</p>
  
  <p>How can I stop logging information and only log things which require my attention, such as errors?</p>
  
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-27T21:42:42.263Z
Comments.Text: Are you sure you don't have devMode enabled in production? https://docs.craftcms.com/v3/config/config-settings.html#devmode
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-27T23:43:08.863Z
Comments.Text: My .env file is set to "production", and in `config/general.php` I'm don't have any `devMode` item in the production array. The linked documentation says the default value is false - so I would assume it should be false.
Comments.UserDisplayName: Tyler
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-12T18:06:18.650Z
Comments.Text: We run into the same issue. We explicitly have devMode set to false in production and our queue and/or console logs generally fill all five files in a manner of minutes. It appears every single SQL query gets written to the log. It is so hard to diagnose issues when all the log files are overwritten/rewritten in a manner of minutes.
Comments.UserDisplayName: Benjamin Kohl
Tags: <craft3><config><logs><logging>
Title: Is it possible to stop Craft from logging so much?
ThreadText: # Is it possible to stop Craft from logging so much?
  
  (Asked by: username_0 on 2018-10-26)
  
  I've got a Craft CMS installation that is set to production mode. I notice that my logs get flooded with a bunch of entries which don't seem very useful.
  
  For example, in a matter of several days, I've already got `console.log` up to `console.log.5` - So it's rotated the log file 5 times already. These files are filled with what seems like every single query that gets executed on the website. They're 70k lines a piece. It also logs a lot of entries in `queue.log`, among other files.
  
  How can I stop logging information and only log things which require my attention, such as errors?
  
  Thanks!
  
  **Tags:** craft3, config, logs, logging
  
  > **Comments:**
  > **username_1**: Are you sure you don't have devMode enabled in production? https://docs.craftcms.com/v3/config/config-settings.html#devmode  
  > **username_0**: My .env file is set to "production", and in `config/general.php` I'm don't have any `devMode` item in the production array. The linked documentation says the default value is false - so I would assume it should be false.  
  > **username_2**: We run into the same issue. We explicitly have devMode set to false in production and our queue and/or console logs generally fill all five files in a manner of minutes. It appears every single SQL query gets written to the log. It is so hard to diagnose issues when all the log files are overwritten/rewritten in a manner of minutes.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_3 on 2018-12-27. Score: 3
  
  As someone who theoretically might inherit your site one day... and also as future-you trying to diagnose a problem... please don't try to limit what Craft logs. If you want a quicker way to look for critical problems, check out the Yii2 Debug Toolbar as discussed here [Profiling your Website with Craft CMS 3’s Debug Toolbar](https://nystudio107.com/blog/profiling-your-website-with-craft-cms-3s-debug-toolbar)
  
  You can use it to very quickly and easily see only errors, or only warnings, and so on. And then if the additional data that Craft logs is needed to help you diagnose a problem, it'll still be there.
  
  To learn how to parse the Craft CMS log files quickly, check out the [Zen and the Art of Craft CMS Log File Reading](https://nystudio107.com/blog/zen-and-the-art-of-craft-cms-log-file-reading)
  
  If you do end up wanting to make your own logger, check out the [Creating a Custom Logger for Craft CMS](https://nystudio107.com/blog/creating-a-custom-logger-for-craft-cms) article
  
  I echo username_1's comments, though, unless for some reason `devMode` is on, it shouldn't be logging every query, except for performance profiling.
  
  
  ---
  
  ### Answer by username_1 on 2018-10-28. Score: 2
  
  This will be a similar answer as here: [Craft 3 large log file sizes](https://craftcms.stackexchange.com/questions/28109/craft-3-large-log-file-sizes/28145#28145)
  
  Basically Craft goes with Yii's default `FileTarget` settings, which is 5 log files of 10MB each before they start rotating out. Those are individual limits for both `web.log` and `console.log` files.
  
  If you want to change those behaviors you'll need to modify those properties via a `config/app.php` file using your own FileTarget settings.
  
  There's another post here with some useful guidance: [Craft 3 plugins - Logging in a separate \*.log file](https://craftcms.stackexchange.com/questions/25427/craft-3-plugins-logging-in-a-separate-log-file/25430#25430)
  
  
  ---
  
  ### Answer by username_4 on 2020-07-13. Score: 1
  
  We were having the same issue. Our logs were getting so dense with SQL statements that it was hard to find our errors. And for the most part, seeing Craft's internal SQL would not help us debug the problem.
  
  What we've found is we can use the [onelogger plugin](https://github.com/onedesign/onelogger). After installing it, we just needed to add a file called onelogger.php to our config file. This is what we used:
  
  ```
  <?php
  
  return [
    'logLevels' => getenv('ONELOGGER_LOG_LEVELS') ? explode(',', getenv('ONELOGGER_LOG_LEVELS')) : ['warning', 'error']
  ];
  
  ```
  
  
  ---
  
  ### Answer by username_5 on 2021-04-27. Score: 1
  
  Even so this thread is old, maybe my answer can help someone:
  [Cleanup Craft Logs](https://craftcms.stackexchange.com/questions/35907/cleanup-craft-logs)
  
  **Basically it's possible via app.php** to remove all unnecessary logs such as all the $\_GET, $\_POST, $\_SERVER variables and all the SQL being logged.
  
  The main point you need is to configure in **app.php** the log component. The entry **'logVars'** will get rid of all the $\_SERVER values logged (also fixed security issues with password appearing in the logs).
  The other interesting configuration is the **'except'** array where we excluded a few classes. 'yii\db\Connection::\*' for example removes all SQL logs.
  
  ```
  return [
      'modules' => [
          'mymodule' => MyModule::class,
          // My modules mapped here
      ],
      'components' => [
          'log' => function() {
              return Craft::createObject([
                  'class' => yii\log\Dispatcher::class,
                  'targets' => [
                      [
                          'class' => codemix\streamlog\Target::class,
                          'url' => 'php://stderr',
                          'levels' => Craft::$app->getConfig()->general->devMode ?
                              (yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING | yii\log\Logger::LEVEL_INFO) :
                              (yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING),
                          'except' => [
                              'yii\base\View::renderFile',
                              'yii\db\Command::*',
                              'yii\db\Connection::*' // We don't want sql to be logged
                          ],
                          // don't log global variables like $_SERVER etc periodically in logs.
                          // See: yii\log\Target::class, collect method usually appends getContextMessage
                          'logVars' => []
                      ]
                  ]
              ]);
          }
      ],
      'bootstrap' => [
          // My module names here
      ],
  ];
  
  ```
  
  
  ---
  
  