<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Briano Trần</title>
    <description>The latest articles on DEV Community by Briano Trần (@bri4n0).</description>
    <link>https://dev.to/bri4n0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1569663%2F8338c478-789d-47d8-a033-3c6d6be44d7e.jpg</url>
      <title>DEV Community: Briano Trần</title>
      <link>https://dev.to/bri4n0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bri4n0"/>
    <language>en</language>
    <item>
      <title>Output Laravel SQL Query log</title>
      <dc:creator>Briano Trần</dc:creator>
      <pubDate>Mon, 03 Jun 2024 18:19:33 +0000</pubDate>
      <link>https://dev.to/bri4n0/output-laravel-sql-query-log-285b</link>
      <guid>https://dev.to/bri4n0/output-laravel-sql-query-log-285b</guid>
      <description>&lt;p&gt;You’ve likely encountered many query issues while developing software with Laravel. You might be wondering why your features are slow or how many queries your function is making to the database. You may not know if you’re experiencing N+1 problems or how to optimize your queries. This package is here to support you with those challenges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install&lt;/strong&gt;&lt;br&gt;
To install via Composer, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require bri4n0/sql-query-log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For version &amp;lt;= 11: Add to section providers of config/app.php:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// config/app.php
'providers' =&amp;gt; [
    ...
    Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For version &amp;gt;= 11: Add to section providers of bootstrap/providers.php:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// bootstrap/providers.php
return [
    ...
    Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set enable SQL query log, Add to .env:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENABLE_SQL_LOG=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Others&lt;/strong&gt;&lt;br&gt;
Custom logging channel:&lt;br&gt;
open file config/logging.php add channel to section channels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  'channels' =&amp;gt; [
    ...,
     'sql-query-log' =&amp;gt; [
            'driver'               =&amp;gt; 'daily',
            'path'                 =&amp;gt; storage_path('logs/queries.log'),
            'days'                 =&amp;gt; env('LOG_DAILY_DAYS', 14),
            'replace_placeholders' =&amp;gt; true,
        ],
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;enable using sql query log channel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQL_LOG_CHANNEL=sql-query-log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Custom logging channel level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQL_LOG_LEVEL=debug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;show more: &lt;a href="https://github.com/bri4n0/sql-query-log"&gt;https://github.com/bri4n0/sql-query-log&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
