Help setting up log for Laravel?
See original GitHub issueHey there!
Great plugin, super useful for quickly viewing log files… Well it was. But it seems Laravel doesn’t match the default provided formats anymore so I was hoping we could get some help.
The general format looks like this:
[2018-08-02 03:03:14] local.ERROR: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "product_id" does not exist
LINE 1: insert into "product_id" ("customer_id", "product_id") value...
^ (SQL: insert into "product_id" ("customer_id", "product_id") values (1838, 2149)) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42P01): SQLSTATE[42P01]: Undefined table: 7 ERROR: relation \"product_id\" does not exist
LINE 1: insert into \"product_id\" (\"customer_id\", \"product_id\") value...
^ (SQL: insert into \"product_id\" (\"customer_id\", \"product_id\") values (1838, 2149)) at /app/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 42P01): SQLSTATE[42P01]: Undefined table: 7 ERROR: relation \"product_id\" does not exist
LINE 1: insert into \"product_id\" (\"customer_id\", \"product_id\") value...
^ at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:144, PDOException(code: 42P01): SQLSTATE[42P01]: Undefined table: 7 ERROR: relation \"product_id\" does not exist
LINE 1: insert into \"product_id\" (\"customer_id\", \"product_id\") value...
^ at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:142)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('insert into \"pr...', Array, Object(Closure))
#1 /app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): Illuminate\\Database\\Connection->run('insert into \"pr...', Array, Object(Closure))
Of note is that the new log message always starts with [{date} {time}] {category}.{severity}:
Also, there are some lines that start with a [
that are not new entries e.g. [stacktrace]
.
Another example of an info log entry would be:
[2018-08-02 03:02:42] custom.INFO: Successfully imported customer 123456
[2018-08-02 03:02:42] custom.INFO: Successfully imported customer 653512
So, I’d love some assistance in what patterns I should use to support this format?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:36
Top Results From Across the Web
Logging - Laravel - The PHP Framework For Web Artisans
Laravel logging is based on "channels". Each channel represents a specific way of writing log information. For example, the single channel writes log...
Read more >Laravel Logging Tutorial - Stackify
Setting up a channel for Retrace specifically · Step 1. Use composer to install the Stackify Monolog handler package · Step 2. Set...
Read more >How to Get Started with Logging in Laravel - Better Stack
Logging in Laravel is channel-based, and each channel defines a specific way of writing log messages. For example, the single channel writes log...
Read more >Laravel Logging: Everything You Need To Know - Kinsta
Logging is vital to monitoring the health and efficacy of your development projects. Learn how to apply structured logging in Laravel.
Read more >Laravel Logging: Tutorial and Best Practices - ContainIQ
The default Laravel logging setup is easy to get started with, but as applications get more complicated and distributed, this basic logging sometimes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this: Message pattern:
^\[(.*)\] (.+?)\.([A-Z]+): (.*)
Message start pattern:^\[
Time format:yyyy-MM-dd HH:mm:ss
Time capture group:1
Severity capture group:3
Category capture group:2
I’m using Laravel-Log-Enhancer to add extra info to my logs.
Format with enhanced logs:
^\[([\d\s:-]+)\] ([^.]+)\.([^:]+): (.*)(\{*\})$
Format without:
^\[([\d\s:-]+)\] ([^.]+)\.([^:]+): (.*)$
Patterns:
^[^.]+\.(ERROR):
^[^.]+\.(WARNING):
^[^.]+\.(INFO):
^[^.]+\.(ALERT):
^[^.]+\.(DEBUG):
^[^.]+\.(CRITICAL):