question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help setting up log for Laravel?

See original GitHub issue

Hey 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:open
  • Created 5 years ago
  • Reactions:21
  • Comments:36

github_iconTop GitHub Comments

85reactions
atamansvcommented, Sep 20, 2018

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

29reactions
Michael-Stokoecommented, Nov 11, 2019

image

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):

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found