Php Laravel 5.4,始终记录;未经认证。”;记录文件和一些未知错误

Php Laravel 5.4,始终记录;未经认证。”;记录文件和一些未知错误,php,laravel,laravel-5.4,Php,Laravel,Laravel 5.4,我正在构建一个Laravel 5.4应用程序,并已将我的routes\web.php设置如下: <?php Route::get('/', 'PublicController@home')->name('home'); Route::get('/about', 'PublicController@about')->name('about'); Route::get('/contact', 'PublicController@contact')->name('conta

我正在构建一个Laravel 5.4应用程序,并已将我的routes\web.php设置如下:

<?php

Route::get('/', 'PublicController@home')->name('home');

Route::get('/about', 'PublicController@about')->name('about');
Route::get('/contact', 'PublicController@contact')->name('contact');
Route::post('/contact', 'PublicController@sendMessage')->name('contact.send');

Route::prefix('admin')->group(function () {
    Auth::routes();
    Route::middleware(['auth'])->group(function () {

        Route::get('/', 'DashboardController@index')->name('dashboard');

        Route::get('user', 'UserController@index')->name('user.profile');
        Route::post('user/update', 'UserController@update')->name('user.update');
    });
});
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{

    protected $dontReport = [
        \Illuminate\Auth\AuthenticationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
    ];

    public function report(Exception $e)
    {
        if (!config('app.debug')) {
            \Log::error('['.$e->getCode().'] "'.$e->getMessage().'" on line '.$e->getTrace()[0]['line'].' of file '.$e->getTrace()[0]['file']);
        } else {
            parent::report($e);
        }
    }

    public function render($request, Exception $exception)
    {
        return parent::render($request, $exception);
    }

    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest(route('login'));
    }
}
'log_level' => env('APP_LOG_LEVEL', 'error'),
[2019-05-21 05:12:47] production.ERROR: [0] "Unauthenticated." on line 294 of file
 D:\laragon\www\myproject\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php  
[2019-05-21 05:12:47] production.ERROR: [0] "" on line 546 of file
 D:\laragon\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\Router.php 
现在,每当我访问任何公共路由,例如mydomain.com/或mydomain.com/about时,重定向工作正常,没有任何前端错误,但Laravel将以下错误记录到日志文件中:

[2019-05-21 05:12:32] production.ERROR: [0] "" on line 546 of file
D:\laragon\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\Router.php 
如果我访问任何管理(受保护)路由,例如mydomain.com/admin或mydomain.com/admin/user,前端同样没有错误,但获取的日志条目如下:

<?php

Route::get('/', 'PublicController@home')->name('home');

Route::get('/about', 'PublicController@about')->name('about');
Route::get('/contact', 'PublicController@contact')->name('contact');
Route::post('/contact', 'PublicController@sendMessage')->name('contact.send');

Route::prefix('admin')->group(function () {
    Auth::routes();
    Route::middleware(['auth'])->group(function () {

        Route::get('/', 'DashboardController@index')->name('dashboard');

        Route::get('user', 'UserController@index')->name('user.profile');
        Route::post('user/update', 'UserController@update')->name('user.update');
    });
});
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{

    protected $dontReport = [
        \Illuminate\Auth\AuthenticationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
    ];

    public function report(Exception $e)
    {
        if (!config('app.debug')) {
            \Log::error('['.$e->getCode().'] "'.$e->getMessage().'" on line '.$e->getTrace()[0]['line'].' of file '.$e->getTrace()[0]['file']);
        } else {
            parent::report($e);
        }
    }

    public function render($request, Exception $exception)
    {
        return parent::render($request, $exception);
    }

    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest(route('login'));
    }
}
'log_level' => env('APP_LOG_LEVEL', 'error'),
[2019-05-21 05:12:47] production.ERROR: [0] "Unauthenticated." on line 294 of file
 D:\laragon\www\myproject\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php  
[2019-05-21 05:12:47] production.ERROR: [0] "" on line 546 of file
 D:\laragon\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\Router.php 
现在我的问题是:

  • 为什么我在生产环境中得到“未经验证”的日志条目
  • 为什么laravel在访问任何公共或受保护的路由时记录空路由错误(第546行的production.error:[0]”

  • p.S.我使用的是PHP 7.2.11版

    尝试使用
    Auth::routes()
    Route::prefix('admin')->组(函数()
    已经这样做了,并且仍然获得相同的错误日志条目。进一步放入
    Auth::routes()
    前缀组之外的前缀也将从后端URL中删除前缀admin/login或admin/dashboard。如果运行
    php artisan route:list
    它会显示任何错误吗?完全没有错误,我甚至尝试运行了所有可能的artisan命令,如
    route:clear
    route:cache
    config:clear
    config:cache
    清除编译
    等,并且每个命令都成功运行