简体   繁体   中英

How to get error information in Laravel?

I'm building an API in Laravel , but if I have an error I just get a 500 response with no extended information.
Laravel also no longer seems to be writing anything to the laravel.log file.

My .env has:

APP_DEBUG=true
APP_LOG_LEVEL=debug

What's the best way to find out why errors are occurring, without relying on HTML-generated response pages?

I'm guessing that what is happening is that a constructor is failing somewhere. Either the constructor for the request object (because you have used validation in a custom request class) or a constructor for one of the API controller classes or a dependency injected class.

Fir the first issue - I would advise against custom request classes and do the validation manually once your API function is entered.

For the second issue you may have to do some specific error logging in the constructors of your controller class and the classes that get injected in there as dependencies. There is a top level exception handler class and you can also try doing some logging in there: https://laravel.com/docs/5.3/errors#the-exception-handler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM