This article mainly introduces the usage of Laravel logs, and analyzes the functions, definitions, usage methods and related precautions of Laravel logs in detail in the form of examples. Friends in need can refer to the following
Examples of this article Laravel log usage. Share it with everyone for your reference, the details are as follows:
The Laravel version used here is still 5.2
The log is very important. Debug mode can be turned on for local development, but viewing logs for online projects is a very simple and effective way to debug. Laravel integrates the Monolog logging library to provide a variety of powerful log processors.
Laravel supports log methods single, daily, syslog and errorlog. For example, if you want log files to be generated on a daily basis instead of generating a single file, you should set the log value in the configuration file config/app.php as follows:
1 |
|
The system default configuration is single
1 2 |
|
Let’s take a look at how Laravel configures logs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
If you customize the Monolog configuration, use the if condition, and the default is else
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
The useFiles method here is to register the signle file log handler and set the storage file and storage level.
The following are four log processing registration methods when initializing logs.
1 2 3 4 |
|
The log initialization information is basically the above.
You can use the Log facade to write log information into the log:
Eight log levels: emergency, alert, critical, error, warning, notice, info and debug.
1 2 3 4 5 6 7 8 |
|
The above is the entire content of this article. I hope it will be helpful to everyone’s study. Please pay attention to more related content. PHP Chinese website!
Related recommendations:
About the use of cookies in Laravel5
Learn several usages of laravel’s model events
The above is the detailed content of About Laravel log usage. For more information, please follow other related articles on the PHP Chinese website!