# 调试

* 接口调试可通过POSTMAN来进行.
* 异常处理可依赖, 系统日志.
* 微信调试, 可以依赖微信日志.
* 正式环境强烈建议使用 *SENTRY*, 捕获错误并及时处理

## 日志调试

### 系统日志

* 系统日志 DEBUG/INFO/NOTICE/WARNING/ERROR/CRITICAL/EMERGENCY
* 数据库执行日志

  ```php
  # 修改 .env
  DOCTRINE_LOGGER=LaravelDoctrine\ORM\Loggers\FileLogger
  ```

系统日常默认放置在 *storage/logs/lumen.log*

可参考: [lumen Errors & Logging](https://lumen.laravel.com/docs/5.4/errors)

### 微信调试

* 微信开放平台第三方平台日志
* 微信公众号日志
* 微信小程序日志

日志默认放置在 *storage/logs/wechat.log*

## 手动异常抛出

有的场景捕获异常后, 依然需要完整的*Exception*抛出, 以便问题排查, 这是可以通过*app('api.exception')->report($e)*&#x8FDB;行抛错

例如:

```php
try {
    #.....
} catch (Exception $e) {
    $status = 'fail';

    app('api.exception')->report($e)

    $exceptionMessage = $e->getMessage();

    #...
}
```

## SENTRY异常捕获平台

可配&#x7F6E;*.env*

```php
SENTRY_LARAVEL_DSN=
```

参考:

* [SENTRY官方文档](https://sentry.io)
* [sentry使用实践](https://www.jianshu.com/p/66e00077fac3)

## 记录日志

```php
app('log')->debug('debug');
app('log')->info('info');
app('log')->notice('notice');
app('log')->warning('warning');
app('log')->error('error');
app('log')->crit('critical');
app('log')->alert('alert');
app('log')->emerg('emerg');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://espier.gitbook.io/espier/kuang-jia/debug.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
