Recently, I had to browse some logs to debug a flow, and it started to get a bit tiring, looking for those keywords. Of course, there is the search shortcut Ctrl + F
but when you want a bit more than that, or just something faster, PHPStorm comes in to help.
Log Format
PHPStorm comes with a few log formats already configured, but also allows you to define a new one. To do so, go into Settings -> Editor -> Log Highlighting (Ideolog)
(you can also hit double shift
and type Log formats
.
There, you will be able to add a new Log format. Let’s name it Symfony, and give it the following config:
Name: Symfony
Message Pattern: ^\[(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\]\s+(\w+).(\w+):\s+(.*)$
Message start pattern: ^\[
Time format: yyyy-MM-dd HH:mm:ss
Time capture group: 1
Severity capture group: 3
Category capture group: 2
You should also add a Pattern for the messages which is: ^\s*c(ritical)?\s*$
and perhaps apply red colour to it.
Enjoy your logs!
That’s it – from now on, you will enjoy some colourful logfile, making your debug process way easier!
![](/_next/image?url=https%3A%2F%2Fapi.locastic.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreenshot-from-2021-03-24-15-18-17-1024x161.png&w=3840&q=70)
I have to point out, the idea was inspired by Github user dszczer in this cheat sheet, so huge thanks for his work and contribution.