New in Symfony 5.4: Configurable Exceptions

Contributed by Grégoire Pineau in #42244.

In Symfony applications, logging is available either via Symfony's built-in logger and or via the Monolog logger and its tight integration with Symfony. When using Monolog you can access to features such as excluding certain HTTP codes from logs and logging messages to different files. In Symfony 5.4 we've improved the logger with a new feature to make exceptions configurable per class. Using the new framework.exceptions option you can now define the log level and the HTTP status of the exceptions associated to a certain class:

    1

2 3 4 5 6 7 8 9

config/packages/framework.yaml

framework: exceptions: Symfony\Component\HttpKernel\Exception\BadRequestHttpException: log_level: debug status_code: 422 App\Something\Exception\SomeException: log_level: alert status_code: 503

Although this example uses the YAML config format, this feature is also available when using XML or PHP as the config format.

                Sponsor the Symfony project.

https://symfony.com/blog/new-in-symfony-5-4-configurable-exceptions?utm_source=Symfony%20Blog%20Feed&utm_medium=feed

Établi 3y | 15 nov. 2021 à 10:20:07


Connectez-vous pour ajouter un commentaire

Autres messages de ce groupe

SymfonyLive Paris 2025 : Développer avec API Platform 4, ça change quoi ?

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here.

Al

4 févr. 2025 à 09:20:06 | Symfony
SymfonyLive Berlin 2025: Where have the women of tech history gone?

SymfonyLive Berlin 2025, conference held in English, will take place from April 1 to 4! The schedule is being revealed gradually. More details are available here.

As we are now unveiling th

3 févr. 2025 à 14:40:15 | Symfony
A Week of Symfony #944 (27 January - 2 February 2025)

This week, Symfony released maintenance versions 6.4.18, 7.1.11 and 7.2.3. In addition, Twig published a security advisory and we shared several updates about upcoming Symfony conferences. Lastly, Sym

2 févr. 2025 à 10:50:16 | Symfony
Back on the inspiring SymfonyCon Vienna 2024!

We were absolutely thrilled to gather with the incredible Symfony community for the first time in Vienna, Austria, from December 5th to 6th, surrounded by the warm and festive atmosphere of the

31 janv. 2025 à 12:30:18 | Symfony
SymfonyLive Paris 2025 : Reveal of workshop topics!

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here.

💻

30 janv. 2025 à 08:50:03 | Symfony
Get Symfony news on your favorite social network

Symfony has been active on X, Mastodon, and Bluesky for some time, but until recently, not all platforms received equal attention. Since Twitter (now X) was our first social network, all blog posts we

29 janv. 2025 à 14:20:10 | Symfony
SymfonyLive Berlin 2025: Demystify the magic of the Container

SymfonyLive Berlin 2025, conference held in English, will take place from April 1 to 4! The schedule is being revealed gradually. More details are available here.

As we are now unveiling th

29 janv. 2025 à 14:20:10 | Symfony