|
13 | 13 | - [Customizing Monolog For Channels](#customizing-monolog-for-channels)
|
14 | 14 | - [Creating Monolog Handler Channels](#creating-monolog-handler-channels)
|
15 | 15 | - [Creating Custom Channels Via Factories](#creating-custom-channels-via-factories)
|
| 16 | +- [Tailing Log Messages Using Pail](#tailing-log-messages-using-pail) |
| 17 | + - [Installation](#pail-installation) |
| 18 | + - [Usage](#pail-usage) |
| 19 | + - [Filtering Logs](#pail-filtering-logs) |
16 | 20 |
|
17 | 21 | <a name="introduction"></a>
|
18 | 22 | ## Introduction
|
@@ -444,3 +448,86 @@ Once you have configured the `custom` driver channel, you're ready to define the
|
444 | 448 | return new Logger(/* ... */);
|
445 | 449 | }
|
446 | 450 | }
|
| 451 | + |
| 452 | +<a name="tailing-log-messages-using-pail"></a> |
| 453 | +## Tailing Log Messages Using Pail |
| 454 | + |
| 455 | +Often you may need to tail your application's logs in real time. For example, when debugging an issue or when monitoring your application's logs for specific types of errors. |
| 456 | + |
| 457 | +Laravel Pail is a package that allows you to easily dive into your Laravel application's log files directly from the command line. Unlike the standard `tail` command, Pail is designed to work with any log driver, including Sentry or Flare. In addition, Pail provides a set of useful filters to help you quickly find what you're looking for. |
| 458 | + |
| 459 | +<img src="https://laravel.com/img/docs/pail-example.png"> |
| 460 | + |
| 461 | +<a name="pail-installation"></a> |
| 462 | +### Installation |
| 463 | + |
| 464 | +> **Warning** |
| 465 | +> Laravel Pail requires [PHP 8.2+](https://php.net/releases/) and the [PCNTL](https://www.php.net/manual/en/book.pcntl.php) extension. |
| 466 | +
|
| 467 | +To get started, install Pail into your project using the Composer package manager: |
| 468 | + |
| 469 | +```bash |
| 470 | +composer require laravel/pail |
| 471 | +``` |
| 472 | + |
| 473 | +<a name="pail-usage"></a> |
| 474 | +### Usage |
| 475 | + |
| 476 | +To start tailing logs, run the `pail` command: |
| 477 | + |
| 478 | +```bash |
| 479 | +php artisan pail |
| 480 | +``` |
| 481 | + |
| 482 | +To increase the verbosity of the output and avoid truncation (…), use the `-v` option: |
| 483 | + |
| 484 | +```bash |
| 485 | +php artisan pail -v |
| 486 | +``` |
| 487 | + |
| 488 | +For maximum verbosity and to display exception stack traces, use the `-vv` option: |
| 489 | + |
| 490 | +```bash |
| 491 | +php artisan pail -vv |
| 492 | +``` |
| 493 | + |
| 494 | +To stop tailing logs, press `Ctrl+C` at any time. |
| 495 | + |
| 496 | +<a name="pail-filtering-logs"></a> |
| 497 | +### Filtering Logs |
| 498 | + |
| 499 | +<a name="pail-filtering-logs-filter-option"></a> |
| 500 | +#### `--filter` |
| 501 | + |
| 502 | +You may use the `--filter` option to filter logs by their type, file, message, and stack trace content: |
| 503 | + |
| 504 | +```bash |
| 505 | +php artisan pail --filter="QueryException" |
| 506 | +``` |
| 507 | + |
| 508 | +<a name="pail-filtering-logs-message-option"></a> |
| 509 | +#### `--message` |
| 510 | + |
| 511 | +To filter logs by only their message, you may use the `--message` option: |
| 512 | + |
| 513 | +```bash |
| 514 | +php artisan pail --message="User created" |
| 515 | +``` |
| 516 | + |
| 517 | +<a name="pail-filtering-logs-level-option"></a> |
| 518 | +#### `--level` |
| 519 | + |
| 520 | +The `--level` option may be used to filter logs by their [log level](#log-levels): |
| 521 | + |
| 522 | +```bash |
| 523 | +php artisan pail --level=error |
| 524 | +``` |
| 525 | + |
| 526 | +<a name="pail-filtering-logs-user-option"></a> |
| 527 | +#### `--user` |
| 528 | + |
| 529 | +To only display logs that were written while a given user was authenticated, you may provide the user's ID to the `--user` option: |
| 530 | + |
| 531 | +```bash |
| 532 | +php artisan pail --user=1 |
| 533 | +``` |
0 commit comments