如何查看linux的系统log日志

时间:2023-01-28 15:58:58

1.查看系统日志所存放的位置

通过nginx的配置文件查看 default 。
access_log /var/log/nginx/hej.access.log common;

2.查看系统日志的格式

通过nginx的配置文件查看 nginx.conf。(如果是apache,对应找到httpd文件)
log_format apinpai '$remote_addr $host - [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';

3.通过命令进入日志

 cd /var/log/nginx/

4.查看日志 访问前十的 信息

 cat hej.access.log | awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}' | sort | uniq -c | sort -nr | head -10cat hejian.access.log 
| awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}' | sort | uniq -c | sort -nr | head -10