Skip to content

Commit 723887a

Browse files
authored
[Chore] Add logging configuration file and set stderr as the default (alexjustesen#1958)
1 parent d40e4f7 commit 723887a

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

config/logging.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
use Monolog\Handler\NullHandler;
4+
use Monolog\Handler\StreamHandler;
5+
use Monolog\Handler\SyslogUdpHandler;
6+
use Monolog\Processor\PsrLogMessageProcessor;
7+
8+
return [
9+
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Default Log Channel
13+
|--------------------------------------------------------------------------
14+
|
15+
| This option defines the default log channel that is utilized to write
16+
| messages to your logs. The value provided here should match one of
17+
| the channels present in the list of "channels" configured below.
18+
|
19+
*/
20+
21+
'default' => env('LOG_CHANNEL', 'stderr'),
22+
23+
/*
24+
|--------------------------------------------------------------------------
25+
| Deprecations Log Channel
26+
|--------------------------------------------------------------------------
27+
|
28+
| This option controls the log channel that should be used to log warnings
29+
| regarding deprecated PHP and library features. This allows you to get
30+
| your application ready for upcoming major versions of dependencies.
31+
|
32+
*/
33+
34+
'deprecations' => [
35+
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36+
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
37+
],
38+
39+
/*
40+
|--------------------------------------------------------------------------
41+
| Log Channels
42+
|--------------------------------------------------------------------------
43+
|
44+
| Here you may configure the log channels for your application. Laravel
45+
| utilizes the Monolog PHP logging library, which includes a variety
46+
| of powerful log handlers and formatters that you're free to use.
47+
|
48+
| Available drivers: "single", "daily", "slack", "syslog",
49+
| "errorlog", "monolog", "custom", "stack"
50+
|
51+
*/
52+
53+
'channels' => [
54+
55+
'stack' => [
56+
'driver' => 'stack',
57+
'channels' => explode(',', env('LOG_STACK', 'single')),
58+
'ignore_exceptions' => false,
59+
],
60+
61+
'single' => [
62+
'driver' => 'single',
63+
'path' => storage_path('logs/laravel.log'),
64+
'level' => env('LOG_LEVEL', 'debug'),
65+
'replace_placeholders' => true,
66+
],
67+
68+
'daily' => [
69+
'driver' => 'daily',
70+
'path' => storage_path('logs/laravel.log'),
71+
'level' => env('LOG_LEVEL', 'debug'),
72+
'days' => env('LOG_DAILY_DAYS', 14),
73+
'replace_placeholders' => true,
74+
],
75+
76+
'slack' => [
77+
'driver' => 'slack',
78+
'url' => env('LOG_SLACK_WEBHOOK_URL'),
79+
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
80+
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
81+
'level' => env('LOG_LEVEL', 'critical'),
82+
'replace_placeholders' => true,
83+
],
84+
85+
'papertrail' => [
86+
'driver' => 'monolog',
87+
'level' => env('LOG_LEVEL', 'debug'),
88+
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
89+
'handler_with' => [
90+
'host' => env('PAPERTRAIL_URL'),
91+
'port' => env('PAPERTRAIL_PORT'),
92+
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
93+
],
94+
'processors' => [PsrLogMessageProcessor::class],
95+
],
96+
97+
'stderr' => [
98+
'driver' => 'monolog',
99+
'level' => env('LOG_LEVEL', 'debug'),
100+
'handler' => StreamHandler::class,
101+
'formatter' => env('LOG_STDERR_FORMATTER'),
102+
'with' => [
103+
'stream' => 'php://stderr',
104+
],
105+
'processors' => [PsrLogMessageProcessor::class],
106+
],
107+
108+
'syslog' => [
109+
'driver' => 'syslog',
110+
'level' => env('LOG_LEVEL', 'debug'),
111+
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
112+
'replace_placeholders' => true,
113+
],
114+
115+
'errorlog' => [
116+
'driver' => 'errorlog',
117+
'level' => env('LOG_LEVEL', 'debug'),
118+
'replace_placeholders' => true,
119+
],
120+
121+
'null' => [
122+
'driver' => 'monolog',
123+
'handler' => NullHandler::class,
124+
],
125+
126+
'emergency' => [
127+
'path' => storage_path('logs/laravel.log'),
128+
],
129+
130+
],
131+
132+
];

0 commit comments

Comments
 (0)