augusl / laravel-lark-logging
A Laravel package for logging to Lark bot
Requires
- php: ^8.2
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- monolog/monolog: ^3.2
Requires (Dev)
- illuminate/container: ^11.0|^12.0|^13.0
- laravel/pint: ^1.13
- phpunit/phpunit: ^10.5|^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-01 03:51:51 UTC
README
Send Laravel logs to a Lark or Feishu chat through a custom bot webhook.
Install
This package supports Laravel 11, 12, and 13 on PHP 8.2+. Laravel 13 itself requires PHP 8.3+.
composer require augusl/laravel-lark-logging
Define Lark Bot Webhook URL in your .env file
LARK_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/<your-hook-id-xxxxxx>
Add to config/logging.php file new channel:
'lark' => [ 'driver' => 'custom', 'via' => PosAppVN\LarkLogger\LarkLogger::class, 'level' => 'debug', 'title' => env('APP_NAME', 'Laravel Log'), 'retries' => 3, ],
Publish the package config file:
php artisan vendor:publish --provider "PosAppVN\LarkLogger\LarkLoggerServiceProvider"
Custom colors by log level
The default mapping remains compatible with previous releases: errors are red, warnings are yellow, info and notice records are blue, and debug records are purple. Override only the levels needed by a channel:
'lark-app-store' => [ 'driver' => 'custom', 'via' => PosAppVN\LarkLogger\LarkLogger::class, 'level' => 'debug', 'webhook_url' => env('LARK_APP_STORE_WEBHOOK_URL'), 'title' => 'App Store Monitor', 'level_colors' => [ 'info' => 'green', 'warning' => 'red', ], ],
Level names are case-insensitive. Partial overrides fall back to the default mapping. The selected color is applied to both the card header and level tag, so use a color supported by both Lark or Feishu card elements.
Create bot
Create a custom bot by following the Feishu custom bot guide.
Configure a different webhook per channel
Add webhook_url, title, or level_colors to individual channels in
config/logging.php:
[
'channels' => [
'lark-log' => [
'driver' => 'custom',
'via' => PosAppVN\LarkLogger\LarkLogger::class,
'level' => 'debug',
'webhook_url' => 'https://open.feishu.cn/open-apis/bot/v2/hook/<your-hook-id-xxxxxx>',
'title' => 'Laravel Log',
],
'lark-system' => [
'driver' => 'custom',
'via' => PosAppVN\LarkLogger\LarkLogger::class,
'level' => 'error',
'webhook_url' => 'https://open.feishu.cn/open-apis/bot/v2/hook/<your-hook-id-xxxxxx>',
'title' => 'System Log',
],
],
]