• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

andersao/laravel-request-logger: HTTP request logger middleware for Laravel

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

andersao/laravel-request-logger

开源软件地址(OpenSource Url):

https://github.com/andersao/laravel-request-logger

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Laravel Request Logger

Request and Response Logger for Laravel

Insiperd by Morgan - Node HTTP request logger

Latest Stable Version Total Downloads Latest Unstable Version License Analytics

Installation

Composer

Add prettus/laravel-request-logger to the "require" section of your composer.json file.

	"prettus/laravel-request-logger": "1.2.*"

Run composer update to get the latest version of the package.

or

Run composer require prettus/laravel-request-logger direct in your terminal

Laravel

In your config/app.php add Prettus\RequestLogger\Providers\LoggerServiceProvider::class to the end of the providers array:

'providers' => array(
    ...,
    Prettus\RequestLogger\Providers\LoggerServiceProvider::class,
),

Publish Configuration

php artisan vendor:publish --provider="Prettus\RequestLogger\Providers\LoggerServiceProvider"

Configuration

In your config/request-logger.php file, you can change configuration for logger

 'logger' => [
    'enabled'   => true,
    'handlers'  => ['Prettus\RequestLogger\Handler\HttpLoggerHandler'],
    'file'      => storage_path("logs/http.log"),
    'level'     => 'info',
    'format'    => 'common'
]
Property Type Default Value Description
enabled boolean true Enable or disable log http
handlers array ['Prettus\RequestLogger\Handler\HttpLoggerHandler'] Instance of the Monolog\Handler\HandlerInterface. (See more)[https://github.com/Seldaek/monolog#handlers]
file string storage_path("logs/http.log") If you are using Prettus\RequestLogger\Handler\HttpLoggerHandler, you can set the file will be saved walk logs
level string info Level logger write: [notice, info, debug, emergency, alert, critical, error, warning]
format string common Format for the log record

Format Interpolation

Variables

Format Description Exemple
{method} Get the request method. PUT
{root} Get the root URL for the application. http://prettus.local
{url} Get the URL (no query string) for the request. http://prettus.local/users
{full-url} Get the full URL for the request. http://prettus.local/users?search=lorem
{path} Get the current path info for the request. /users
{decoded-path} Get the current encoded path info for the request. /users
{remote-addr} Returns the client IP address. 192.168.10.1
{format} Gets the format associated with the mime type. html
{scheme} Gets the request's scheme. http
{port} Returns the port on which the request is made. 80
{query-string} Generates the normalized query string for the Request. ?search=lorem
{remote-user} Returns the user.
{referer} The page address (if any) by which the user agent to the current page
{user-agent} Get user agent Mozilla/5.0 (Windows NT 6.3; WOW64)
{date} Current Date 2015-04-05 14:00:00
{content} Get the response content. {json:response}
{content-length} Get the content length in bytes 4863
{response-time} Response time in ms 231
{status} Http status code 200
{http-version} Http protocol version 1.1
{server[KEY]} $_SERVER Server and execution environment information (See more)[http://php.net/manual/reserved.variables.server.php]
{req[HEADER]} Request Header values
{res[HEADER]} Response Header values

Default formats

Name Format
combined {remote-addr} - {remote-user} [{date}] "{method} {url} HTTP/{http-version}" {status} {content-length} "{referer}" "{user-agent}"
common {remote-addr} - {remote-user} [{date}] "{method} {url} HTTP/{http-version}" {status} {content-length}
dev {method} {url} {status} {response-time} ms - {content-length}
short {remote-addr} {remote-user} {method} {url} HTTP/{http-version} {status} {content-length} - {response-time} ms
tiny {method} {url} {status} {content-length} - {response-time} ms

Examples

{method} {full-url}

[2015-04-03 00:00:00] local.INFO: GET http://prettus.local/user/1?param=lorem ["REQUEST"]

{method} {full-url} {remote-addr} {port}

[2015-04-03 00:00:00] local.INFO: GET http://prettus.local/user/1?param=lorem 192.168.10.1 80 ["REQUEST"]

{method} {root} {url} {full-url} {path} {decoded-path} {remote-addr} {format} {scheme} {port} {query-string}

[2015-04-03 00:00:00] local.INFO: GET http://prettus.local http://prettus.local/user/1 http://prettus.local/user/1?param=lorem user/1 user/1 192.168.10.1 html http 80 param=lorem ["REQUEST"]

[{status}] HTTP:{http-version} {content}

[2015-04-03 00:00:00] local.INFO: [200] HTTP:1.1 {"id":1,"name":"Anderson Andrade", "email":"[email protected]"} ["RESPONSE"]



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap