{"id":5074,"date":"2017-08-03T14:45:49","date_gmt":"2017-08-03T05:45:49","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=5074"},"modified":"2025-03-12T11:26:30","modified_gmt":"2025-03-12T02:26:30","slug":"laravel-5-1-%e3%81%a7%e3%83%ad%e3%82%b0%e5%87%ba%e5%8a%9b%e3%80%81faultline-php%e8%bf%bd%e5%8a%a0%e7%b7%a8","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2017\/08\/03\/laravel-5-1-%e3%81%a7%e3%83%ad%e3%82%b0%e5%87%ba%e5%8a%9b%e3%80%81faultline-php%e8%bf%bd%e5%8a%a0%e7%b7%a8\/","title":{"rendered":"Laravel 5.1 \u3067\u30ed\u30b0\u51fa\u529b\u3001faultline-php\u8ffd\u52a0\u7de8"},"content":{"rendered":"<p>Laravel \u306e\u6b21\u306eLTS\u30015.5\u3082\u305d\u308d\u305d\u308d\u6765\u305d\u3046\u306a\u6628\u4eca\u3067\u3059\u304c\u3001\u307e\u305f5.1\u306e\u30ed\u30b0\u51fa\u529b\u306e\u8a71\u3067\u3059\u3002<\/p>\n<p>\u6628\u65e5\u306eBlog\u306b\u66f8\u3044\u305f\u3088\u3046\u306b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ed\u30b0\u51fa\u529b\u306b faultline-php (<a href=\"https:\/\/github.com\/faultline\/faultline-php\" target=\"_blank\">https:\/\/github.com\/faultline\/faultline-php<\/a>) \u3092\u7d44\u307f\u8fbc\u307f\u307e\u3057\u305f\u3002Monolog integration \u306e\u3042\u308a\u304c\u305f\u3055\u3088\u3002<\/p>\n<p>\u4eca\u65e5\u306f faultline \u95a2\u4fc2\u306e .env \u5bfe\u5fdc\u3092\u9032\u3081\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u30b3\u30fc\u30c9\u304c\u3084\u3084\u3053\u3057\u304f\u306a\u308b\u524d\u306e\u7d20\u6734\u306a\u306e\u3092\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u51fa\u3057\u3066\u304a\u3053\u3046\u304b\u306a\u301c\u3068\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u7d44\u307f\u8fbc\u307f\u524d\u306e\u72b6\u614b\u306b\u3064\u3044\u3066\u306f<a href=\"http:\/\/www.lancard.com\/blog\/2017\/02\/01\/laravel-5-1-%e3%81%a7%e3%83%ad%e3%82%b0%e5%87%ba%e5%8a%9b%e3%80%81%e3%81%9d%e3%82%8c%e3%81%8b%e3%82%89-%e3%83%ad%e3%82%b0%e3%83%a1%e3%83%bc%e3%83%ab%e3%83%89%e3%83%a9%e3%82%a4%e3%83%90%e3%83%bc\/\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>class AppServiceProvider extends ServiceProvider\n{\n    public function boot()\n    {\n        \/\/\u767b\u9332\u3055\u308c\u305flogger\u306ehandler\u3092\u7f6e\u304d\u63db\u3048\u308b\n        $monolog = \\Log::getMonolog();\n        $monolog-&gt;popHandler(); \/\/\u65e2\u5b58\u306ehandler\u3092\u524a\u9664\n        $monolog-&gt;pushHandler(\n                    (new \\Monolog\\Handler\\RotatingFileHandler(\n                        $this-&gt;app-&gt;storagePath() . '\/logs\/' \n                            . $this-&gt;app-&gt;environment() . '_'\n                            . (defined('ARTISAN_BINARY') ? ARTISAN_BINARY . '_' : '')\n                            . posix_getpwuid(posix_geteuid())['name'] \n                            . '.log',\n                        \\Config::get('app.log_max_files', 5),\n                        (\\Config::get('app.debug') || $this-&gt;app-&gt;environment('testing')) \n                            ? \\Monolog\\Logger::DEBUG \n                            : \\Monolog\\Logger::INFO \/\/\u51fa\u529b\u30ec\u30d9\u30eb\u5236\u5fa1\u306e\u305f\u3081\u8ffd\u52a0\n                    ))\n                    -&gt;setFormatter(new \\Monolog\\Formatter\\LineFormatter(null, null, true))\n                );\n        \/\/Faultline\\MonologHandler\u3092\u8ffd\u52a0\u3002Notifier\u306fregister()\u3067\u884c\u3063\u3066\u3044\u308b\u30d0\u30a4\u30f3\u30c9\u304b\u3089\u53d6\u5f97\u3002\n        $monolog-&gt;pushHandler(new \\Faultline\\MonologHandler(App('faultline.notifier')));\n        $monolog-&gt;pushProcessor(\n                    new \\Monolog\\Processor\\IntrospectionProcessor(\n                        \\Monolog\\Logger::NOTICE,    \/\/DEBUG,INFO\u306f\u767a\u751f\u5834\u6240\u306e\u60c5\u5831\u3092\u4ed8\u52a0\u3057\u306a\u3044\n                        [\n                            'Illuminate\\\\',\n                            \/\/\u4ed6\u3001\u547c\u3073\u51fa\u3057\u5143\u3068\u3057\u3066\u306f\u30b9\u30ad\u30c3\u30d7\u3057\u305f\u3044\u5bfe\u8c61\u3092\u8a2d\u5b9a,\n                        ]\n                    )\n                );\n\n        \/\/.env\u306eAPP_QUERY_LOGGING\u304ctrue\u306e\u5834\u5408\u30af\u30a8\u30ea\u3092\u72ec\u81ea\u30ed\u30b0query_{\u5b9f\u884c\u30a2\u30ab\u30a6\u30f3\u30c8}.log\u306b\u51fa\u529b\u3059\u308b\u3002\n        if(env('APP_QUERY_LOGGING', false)) {\n            \\DB::listen(function($query, $bindings, $time){\n                $queryLogger = (new \\Monolog\\Logger(\n                    $this-&gt;app-&gt;environment()\n                ))-&gt;pushHandler(\n                    new \\Monolog\\Handler\\StreamHandler (\n                        $this-&gt;app-&gt;storagePath() . '\/logs\/query_' . posix_getpwuid(posix_geteuid())['name'] . '.log')\n                );\n\n                $queryLogger-&gt;info('QUERY:[' . $query . '] BINDINGS:'\n                        . json_encode($bindings), ['TIME' =&gt; $time]);\n            });\n        }\n    }\n\n    public function register()\n    {\n        \/\/faultline.notifier \u30d0\u30a4\u30f3\u30c9\n        $this-&gt;app-&gt;bind('faultline.notifier', function($app) {\n            return new \\Faultline\\Notifier([\n                'project' =&gt; \"project_name_{$app-&gt;env}\",\n                'apiKey' =&gt; 'XXxxXXXXxxxXXXxxxxXXXxxxXXX',\n                'endpoint' =&gt; 'https:\/\/xXXXXxxxX.execute-api.ap-northeast-1.amazonaws.com\/v0',\n                'notifications' =&gt; [\n                    [\n                        'type'=&gt; 'slack',\n                        'endpoint'=&gt; 'https:\/\/hooks.slack.com\/services\/XXxxxxXXXxxxXXX\/XXxxXXxXXXxxxxXXXxxxXXX',\n                        'channel'=&gt; '#faultline',\n                        'username'=&gt; 'faultline-notify',\n                        'notifyInterval'=&gt; 5,\n                        'threshold'=&gt; 10,\n                        'timezone'=&gt; 'Asia\/Tokyo'\n                    ],\n                ]\n            ]);\n        });\n    }\n}\n<\/code><\/pre>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074&#038;t=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074&#038;text=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074&#038;title=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Laravel%205.1%20%E3%81%A7%E3%83%AD%E3%82%B0%E5%87%BA%E5%8A%9B%E3%80%81faultline-php%E8%BF%BD%E5%8A%A0%E7%B7%A8&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F5074\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>Laravel \u306e\u6b21\u306eLTS\u30015.5\u3082\u305d\u308d\u305d\u308d\u6765\u305d\u3046\u306a\u6628\u4eca\u3067\u3059\u304c\u3001\u307e\u305f5.1\u306e\u30ed\u30b0\u51fa\u529b\u306e\u8a71\u3067\u3059\u3002 \u6628\u65e5\u306eBlog\u306b\u66f8\u3044\u305f\u3088\u3046\u306b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ed\u30b0\u51fa\u529b\u306b faultline-php (https:\/\/github.com\/ [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[163,130],"class_list":["post-5074","post","type-post","status-publish","format-standard","hentry","category-php","tag-faultline","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=5074"}],"version-history":[{"count":7,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5074\/revisions"}],"predecessor-version":[{"id":5081,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/5074\/revisions\/5081"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=5074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=5074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=5074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}