<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Monolog | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/tag/monolog/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Thu, 27 Aug 2026 06:54:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>Enable Sentry Bundle Logging</title>
		<link>https://nerdpress.org/2026/08/26/enable-sentry-bundle-logging/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 26 Aug 2026 15:35:06 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Monolog]]></category>
		<category><![CDATA[Sentry]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3499</guid>

					<description><![CDATA[<p>When using the SentryBundle (Version 5.12.0) in a Symfony project, one might want to log the events it sends to Sentry. This is useful for debugging and monitoring. Here is how to enable it. Configure the LogsHandler Service All following definitions got to sentry.yaml file in your config/packages folder.Define a LogsHandler service with the minimum &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2026/08/26/enable-sentry-bundle-logging/" class="more-link">Continue reading<span class="screen-reader-text"> "Enable Sentry Bundle Logging"</span></a></p>
The post <a href="https://nerdpress.org/2026/08/26/enable-sentry-bundle-logging/">Enable Sentry Bundle Logging</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">When using the <a title="" href="https://github.com/getsentry/sentry-symfony" target="_blank" rel="noopener">SentryBundle</a> (Version 5.12.0) in a Symfony project, one might want to log the events it sends to Sentry. This is useful for debugging and monitoring. Here is how to enable it.</p>



<span id="more-3499"></span>



<p class="wp-block-paragraph"><strong>Configure the LogsHandler Service</strong></p>



<p class="wp-block-paragraph">All following definitions got to <em>sentry.yaml</em> file in your <em>config/packages</em> folder.<br />Define a <em>LogsHandler</em> service with the minimum log level you want to capture:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">services:
  Sentry\SentryBundle\Monolog\LogsHandler:
    <span class="hljs-built_in">arguments</span>:
      - !php/<span class="hljs-keyword">const</span> Monolog\Logger::WARNING</code></span></pre>


<p class="wp-block-paragraph"><br /><strong>Add the Handler to Monolog</strong></p>



<p class="wp-block-paragraph">Add the handler to the <em>monolog</em> configuration:</p>


<pre class="wp-block-code"><span><code class="hljs">monolog:
  handlers:
    sentry:
      type: service
      id: Sentry\SentryBundle\Monolog\LogsHandler</code></span></pre>


<p class="wp-block-paragraph"><strong>Configure the Logger in Sentry</strong></p>



<p class="wp-block-paragraph">Add the main logger service to the SentryBundle configuration:</p>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">sentry</span>:
  <span class="hljs-selector-tag">logger</span>: <span class="hljs-selector-tag">monolog</span><span class="hljs-selector-class">.logger</span></code></span></pre>


<p class="wp-block-paragraph"><strong>Enable Logging</strong></p>



<p class="wp-block-paragraph">Finally, enable logging in the SentryBundle configuration:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">sentry:
  logging:
    enable_logs: <span class="hljs-literal">true</span></code></span></pre>


<p class="wp-block-paragraph"><strong>Result</strong></p>



<p class="wp-block-paragraph">Now, when an exception is captured by the SentryBundle, it will also be logged to the configured logger. For example:</p>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">Sent</span> <span class="hljs-selector-tag">event</span> <span class="hljs-selector-attr">&#91;eaaf669ea6834546a20beb6ae0c5773f]</span> <span class="hljs-selector-tag">to</span> <span class="hljs-selector-tag">sentry</span><span class="hljs-selector-class">.example</span><span class="hljs-selector-class">.com</span> <span class="hljs-selector-attr">&#91;project:12]</span>. <span class="hljs-selector-tag">Result</span>: "<span class="hljs-selector-tag">success</span>" (<span class="hljs-selector-tag">status</span>: 200).</code></span></pre>


<p class="wp-block-paragraph">The Sentry documentation on <a href="https://docs.sentry.io/platforms/php/guides/symfony/integrations/monolog/" target="_blank" rel="noopener" title="">Monolog integration</a> is almost complete. <br /><br />However, it misses the part where the logger service must be configured in the SentryBundle configuration. <br />Without it, the logger defaults to a `NullLogger`, and nothing gets logged.<br /><br />Hope it helps.</p>The post <a href="https://nerdpress.org/2026/08/26/enable-sentry-bundle-logging/">Enable Sentry Bundle Logging</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony deprecation log channel</title>
		<link>https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 13:53:02 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Monolog]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3170</guid>

					<description><![CDATA[<p>Are you annoyed of too many deprecation warnings in you logs of your symfony app?Probably yes because it is really a lot of noise.However deprecation logs are still useful to ensure future compatibility of your app. So since version 5.1 symfony will log deprecations to a dedicated log channel when it exists and ships with &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony deprecation log channel"</span></a></p>
The post <a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/">Symfony deprecation log channel</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">Are you annoyed of too many deprecation warnings in you logs of your symfony app?<br />Probably yes because it is really a lot of noise.<br />However deprecation logs are still useful to ensure future compatibility of your app.</p>



<p class="wp-block-paragraph">So since version 5.1 symfony will log deprecations to a dedicated log channel when it exists and ships with this monolog config:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">monolog:
    channels:
        - deprecation <span class="hljs-comment"># Deprecations are logged in the dedicated "deprecation" channel when it exists</span></code></span></pre>


<p class="wp-block-paragraph">This is added already in the <a href="https://github.com/symfony/recipes/blob/main/symfony/monolog-bundle/3.1/config/packages/prod/deprecations.yaml" target="_blank" rel="noreferrer noopener">recipe</a> and ships when installing symfony.</p>



<p class="wp-block-paragraph">Ok, but the handler for this deprecation channel is not configured, so you have to do this yourself.<br />How? Add this to your monolog config:</p>



<span id="more-3170"></span>


<pre class="wp-block-code"><span><code class="hljs language-javascript">...
when@dev:
   monolog:
       handlers:
           main:
	       type: stream
	       <span class="hljs-attr">path</span>: <span class="hljs-string">"%kernel.logs_dir%/%kernel.environment%.log"</span>
	       <span class="hljs-attr">level</span>: debug
	       <span class="hljs-attr">channels</span>: &#91;<span class="hljs-string">"!event"</span>, <span class="hljs-string">"!deprecation"</span>]
	   <span class="hljs-attr">deprecation</span>:
	       type: rotating_file
	       <span class="hljs-attr">path</span>: <span class="hljs-string">"%kernel.logs_dir%/%kernel.environment%.deprecations.log"</span>
	       <span class="hljs-attr">max_files</span>: <span class="hljs-number">2</span>
	       <span class="hljs-attr">channels</span>: &#91;deprecation]
	   <span class="hljs-attr">console</span>:
	       type: <span class="hljs-built_in">console</span>
	       <span class="hljs-attr">process_psr_3_messages</span>: <span class="hljs-literal">false</span>
               <span class="hljs-attr">channels</span>: &#91;<span class="hljs-string">"!event"</span>, <span class="hljs-string">"!doctrine"</span>, <span class="hljs-string">"!console"</span>, <span class="hljs-string">"!deprecation"</span>]
...
</code></span></pre>


<p class="wp-block-paragraph">What is happening here?<br />We declare a new handler for deprecations named <code>deprecation</code> when in dev environment.<br />This handler listens to the deprecation channel.<br />We declare it as a rotating file since the assumption is we dont need to keep this log entries for longer.<br />The other handlers will ignore the deprecation channel by adding a !deprecation to the channel directive.</p>



<p class="wp-block-paragraph">The deprecation channel was already created and so all deprecations are now not in the main log file but in a dedicated deprecation log file.</p>



<p class="wp-block-paragraph">For production we dont need to edit configuration since the log level here is info and therefore deprecations will not be considered anyway.</p>The post <a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/">Symfony deprecation log channel</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
