logging.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. use Monolog\Handler\StreamHandler;
  3. use Monolog\Handler\SyslogUdpHandler;
  4. return [
  5. 'passing_methods'=>[ //跳过日志的方法
  6. 'finishSave',
  7. ],
  8. 'expire_duration'=>'20', //天数,日志超过时长的就在服务中删除
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Default Log Channel
  12. |--------------------------------------------------------------------------
  13. |
  14. | This option defines the default log channel that gets used when writing
  15. | messages to the logs. The name specified in this option should match
  16. | one of the channels defined in the "channels" configuration array.
  17. |
  18. */
  19. 'default' => env('LOG_CHANNEL', 'daily'),
  20. /*
  21. |--------------------------------------------------------------------------
  22. | Log Channels
  23. |--------------------------------------------------------------------------
  24. |
  25. | Here you may configure the log channels for your application. Out of
  26. | the box, Laravel uses the Monolog PHP logging library. This gives
  27. | you a variety of powerful log handlers / formatters to utilize.
  28. |
  29. | Available Drivers: "single", "daily", "slack", "syslog",
  30. | "errorlog", "monolog",
  31. | "custom", "stack"
  32. |
  33. */
  34. 'channels' => [
  35. 'stack' => [
  36. 'driver' => 'stack',
  37. 'channels' => ['critical',"error","warning","info","debug"],
  38. 'ignore_exceptions' => false,
  39. ],
  40. 'single' => [
  41. 'driver' => 'single',
  42. 'path' => storage_path('logs/laravel.log'),
  43. 'level' => 'debug',
  44. ],
  45. 'daily' => [
  46. 'driver' => 'daily',
  47. 'path' => storage_path('logs/error.log'),
  48. 'level' => 'error',
  49. //'permission' => '0666',
  50. 'days' => 14,
  51. ],
  52. 'debug'=>[
  53. 'driver' => 'daily',
  54. 'tap' => [App\Logging\DebugFormatter::class],
  55. 'path' => storage_path('logs/debug.log'),
  56. 'level' => 'debug',
  57. //'permission' => '0666',
  58. 'days' => 7,
  59. ],
  60. 'critical'=> [
  61. 'driver' => 'single',
  62. 'tap' => [App\Logging\CriticalFormatter::class],
  63. 'path' => storage_path('logs/critical.log'),
  64. 'level' => 'critical',
  65. "bubble"=>false,
  66. ],
  67. 'error'=>[
  68. 'driver' => 'daily',
  69. 'tap' => [App\Logging\ErrorFormatter::class],
  70. 'path' => storage_path('logs/error.log'),
  71. 'level' => 'error',
  72. //'permission' => '0666',
  73. 'days' => 14,
  74. "bubble"=>false,
  75. ],
  76. 'warning'=>[
  77. 'driver' => 'single',
  78. 'tap' => [App\Logging\WarningFormatter::class],
  79. 'path' => storage_path('logs/warning.log'),
  80. 'level' => 'warning',
  81. "bubble"=>false,
  82. ],
  83. 'info'=>[
  84. 'driver' => 'single',
  85. 'tap' => [App\Logging\InfoFormatter::class],
  86. 'path' => storage_path('logs/info.log'),
  87. 'level' => 'info',
  88. "bubble"=>false,
  89. ],
  90. 'slack' => [
  91. 'driver' => 'slack',
  92. 'url' => env('LOG_SLACK_WEBHOOK_URL'),
  93. 'username' => 'Laravel Log',
  94. 'emoji' => ':boom:',
  95. 'level' => 'critical',
  96. ],
  97. 'papertrail' => [
  98. 'driver' => 'monolog',
  99. 'level' => 'debug',
  100. 'handler' => SyslogUdpHandler::class,
  101. 'handler_with' => [
  102. 'host' => env('PAPERTRAIL_URL'),
  103. 'port' => env('PAPERTRAIL_PORT'),
  104. ],
  105. ],
  106. 'stderr' => [
  107. 'driver' => 'monolog',
  108. 'handler' => StreamHandler::class,
  109. 'formatter' => env('LOG_STDERR_FORMATTER'),
  110. 'with' => [
  111. 'stream' => 'php://stderr',
  112. ],
  113. ],
  114. 'syslog' => [
  115. 'driver' => 'syslog',
  116. 'level' => 'debug',
  117. ],
  118. ],
  119. ];