本文整理汇总了PHP中Illuminate\Support\Facades\Log::useFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::useFiles方法的具体用法?PHP Log::useFiles怎么用?PHP Log::useFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Log
的用法示例。
在下文中一共展示了Log::useFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
$viewLog = new Logger('View Logs');
$viewLog->pushHandler(new StreamHandler(storage_path() . '/logs/laravel.log', Logger::INFO));
if ($e instanceof ModelNotFoundException) {
Log::useFiles(storage_path() . '/logs/laravel.log');
$viewLog->addInfo('A 404 error (ModelNotFoundException) has been encountered, ' . 'details are as follows:\\n\\n' . $e->getMessage());
Log::error('A 404 error (ModelNotFoundException) has been encountered, ' . 'details are as follows:\\n\\n' . $e->getMessage());
abort(404);
}
if ($e instanceof ErrorException) {
Log::useFiles(storage_path() . '/logs/laravel.log');
$viewLog->addInfo('A 500 error (ErrorException) has been encountered, ' . 'details are as follows:\\n\\n' . $e->getMessage());
Log::error('A 500 error (ErrorException) has been encountered, ' . 'details are as follows:\\n\\n' . $e->getMessage());
abort(500);
}
return parent::render($request, $e);
}
示例2:
<?php
use Dingo\Api\Facade\API;
use Illuminate\Support\Facades\Log;
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
Log::error($exception);
});
API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
示例3: useFiles
static function useFiles($path)
{
Log::useFiles($path);
}