xyzphp / log by xyzphp

log support in laravel
2,628
0
2
Package Data
Maintainer Username: xyzphp
Maintainer Contact: 501773740@qq.com (xyzphp)
Package Create Date: 2017-06-01
Package Last Update: 2017-06-12
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:22:34
Package Statistics
Total Downloads: 2,628
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

xyzphp/log

log support in laravel

安装/配置

composer require xyzphp/log

或者在你的 composer.json 的 require 部分中添加:

"xyzphp/log": "1.0.*"

下载完毕之后,直接配置 app/config.phpproviders:

        Xyzphp\Log\LogServiceProvider::class,

配置日志文件路径 app/config.php

    
        'log_path' => env('APP_LOG_PATH', storage_path('logs/laravel.log')),

编辑 .env 文件

        APP_LOG_PATH=/tmp/xyzphp.log

使用

    $data = ['name'=>'xyz','sex'=>'男'];
    
    info("info_message",$data);              //记录info 级别的日志
    notice("notice_message",$data);          //记录notice 级别的日志
    debug("debug_message",$data);            //记录debug 级别的日志
    warning("warning_message",$data);        //记录warning 级别的日志
    critical("critical_message",$data);      //记录critical 级别的日志
    alert("alert_message",$data);            //记录alert 级别的日志
    emergency("emergency_message",$data);    //记录emergency 级别的日志

记录格式

    {date} {time} {project_name} {level} {method} {request_url} {cli_ip} {server_ip} {message} {data}
    2017-06-12 15:21:01 ucenter INFO GET http://localhost 127.0.0.1 10.118.1.173 info_message {"name":"xyz","sex":"男"}