目录

程序日志打印

等级

  • DEBUG:详细的debug信息。
  • INFO:感兴趣的事件。像用户登录,SQL日志。
  • NOTICE:正常但有重大意义的事件。
  • WARNING:发生异常,使用了已经过时的API。
  • ERROR:运行时发生了错误,错误需要记录下来并监视,但错误不需要立即处理。
  • CRITICAL:关键错误,像应用中的组件不可用。
  • ALETR:需要立即采取措施的错误,像整个网站挂掉了,数据库不可用。这个时候触发器会通过SMS通知你。

格式

Nginx

$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $upstream_addr $upstream_response_time $request_time

Nodejs

NestJS

private readonly logger = new Logger(class.name);

this.logger.log("logger print");
this.logger.debug("debug print");

PHP

Laravel

Log::info("logger print");
Log::debug("debug print")