Answers.Body: <p>This is usually caused by a plugin performing an element query in its <code>init</code> method (see <a href="https://github.com/craftcms/cms/issues/11033" rel="nofollow noreferrer">this GitHub issue</a> for more detail). I experienced the same error filling up my log files after upgrading to Craft 4, making debugging any other issues via the logfiles a total pain. I was able to track down the culprit by adding the following code to my <code>config/app.php</code> file for my local environment:</p>
  <pre><code>'local' =&gt; [
      'components' =&gt; [
          'log' =&gt; [
              'traceLevel' =&gt; 20,
          ],
      ],
  ],
  </code></pre>
  <p>(shamelessly cribbed from mmikkel's <a href="https://discord.com/channels/456442477667418113/456442867163070466/1006203464570908812" rel="nofollow noreferrer">post</a> on the Craft Discord)</p>
  <p>That gave more detail in the logs that revealed the plugin that was causing the issue, which in my case was the Craft Bulk Edit plugin which was checking user permissions in the <code>init</code> method which resulted in element queries, hence the warning.</p>
  <p>Hopefully the same process will help you track down what's causing the warnings too.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-21T11:11:41.290Z
Answers.Text: That code confirmed that the User Manual plugin is one cause and there is a post on their GitHub issues about it. The other cause is my customised contact-form.php file. I've now posted a seperate post to help solve that issue [link](https://craftcms.stackexchange.com/questions/40035/element-query-executed-before-craft-is-fully-initialized)
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-21T08:42:08.953Z
Answers.LastActivityDate: 2022-10-21T08:42:08.953Z
Answers.UserDisplayName: Martin Spain
Answers.Body: <p>These are warnings, not errors. You can (and probably should) report these as issues to the respective plugin developers, but everything should continue to work as normal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-20T15:08:22.890Z
Answers.Text: The problem with that is that I have another site that I updated and that also has the contact form plugin and I'm not getting any warning in the log on that site. Which implies there is something else going on here.
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-20T14:32:23.733Z
Answers.LastActivityDate: 2022-10-20T14:32:23.733Z
Answers.UserDisplayName: Ben Croker
Body: <p>After updating a site from 3.7 to 4.2.8, in Dev mode and showing the debug toolbar and loading a really simple page (or the control panel) I'm seeing warnings in the log.
  I repeated the update process again and get the same result.</p>
  <p>I've then tried uninstalling some plugins to trace the cause.</p>
  <p>After installing User Manual plugin.</p>
  <p><code>warning  craft\web\View::createTwig  Twig instantiated before Craft is fully initialized.</code></p>
  <p>After installing Craft Contact Form plugin</p>
  <p><code>warning  craft\elements\db\ElementQuery::prepare Element query executed before Craft is fully initialized.</code></p>
  <p>The site appears to be working fine though.</p>
  
Tags: <updates><craft4>
Title: Log warnings "..before Craft is fully initialized"
ThreadText: # Log warnings "..before Craft is fully initialized"
  
  (Asked by: username_0 on 2022-10-20)
  
  After updating a site from 3.7 to 4.2.8, in Dev mode and showing the debug toolbar and loading a really simple page (or the control panel) I'm seeing warnings in the log.
  I repeated the update process again and get the same result.
  
  I've then tried uninstalling some plugins to trace the cause.
  
  After installing User Manual plugin.
  
  `warning craft\web\View::createTwig Twig instantiated before Craft is fully initialized.`
  
  After installing Craft Contact Form plugin
  
  `warning craft\elements\db\ElementQuery::prepare Element query executed before Craft is fully initialized.`
  
  The site appears to be working fine though.
  
  **Tags:** updates, craft4
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-10-21. Score: 3 | Accepted answer
  
  This is usually caused by a plugin performing an element query in its `init` method (see [this GitHub issue](https://github.com/craftcms/cms/issues/11033) for more detail). I experienced the same error filling up my log files after upgrading to Craft 4, making debugging any other issues via the logfiles a total pain. I was able to track down the culprit by adding the following code to my `config/app.php` file for my local environment:
  
  ```
  'local' => [
      'components' => [
          'log' => [
              'traceLevel' => 20,
          ],
      ],
  ],
  
  ```
  
  (shamelessly cribbed from mmikkel's [post](https://discord.com/channels/456442477667418113/456442867163070466/1006203464570908812) on the Craft Discord)
  
  That gave more detail in the logs that revealed the plugin that was causing the issue, which in my case was the Craft Bulk Edit plugin which was checking user permissions in the `init` method which resulted in element queries, hence the warning.
  
  Hopefully the same process will help you track down what's causing the warnings too.
  
  > **Comments:**
  > **username_0**: That code confirmed that the User Manual plugin is one cause and there is a post on their GitHub issues about it. The other cause is my customised contact-form.php file. I've now posted a seperate post to help solve that issue [link](https://craftcms.stackexchange.com/questions/40035/element-query-executed-before-craft-is-fully-initialized)  
  
  ---
  
  ### Answer by username_2 on 2022-10-20. Score: 0
  
  These are warnings, not errors. You can (and probably should) report these as issues to the respective plugin developers, but everything should continue to work as normal.
  
  > **Comments:**
  > **username_0**: The problem with that is that I have another site that I updated and that also has the contact form plugin and I'm not getting any warning in the log on that site. Which implies there is something else going on here.  
  
  ---
  
  