天天看点

linux java 错误日志_linux系统报错日志学习

linux本身会自动记录系统报错日志:/var/log/messages

这个日志记录,我是在什么时候发现其强大的作用的呢?它有点像我们使用php脚本开发接口的时候技术员在重要地方打日志的效果,方便技术人员排错,linux本身也有记录启动相关服务的报错日志。

先贴出我nginx的配置看下

server {

listen80;

server_name lisiqiong.ttyun.com;

root/data/wwwroot/lisiqiong/demo;

location/{

index index.php index.html index.htm;

}

location~.php${

fastcgi_pass127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include/usr/local/nginx/conf/fastcgi_params;

}

#access_log/data/wwwlogs/lisiqiong/access.log;

#error_log/data/wwwlogs/lisiqiong/error.log;

}

一般技术员看到这个都会懵掉,因为怎么看都好像没有问题,看官方手册也没有找到问题所在,但是重启nginx服务的时候却报错

[[email protected]_wechat vhost]# service nginx restart

Restarting nginx (via systemctl): Jobfor nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" fordetails.

[FAILED]

如果有心人去百度,google检索这个错误你会发现很多错误可能都会报这个错哟!那怎么弄呢?懵逼了

最后我仔细的检索发现了牛逼的/var/log/messages这个日志

下面贴错我通过这个查找问题的所在问题

cat /var/log/messages|grepnginx

Feb16 14:26:35 Dev_wechat nginx: Starting nginx: nginx: [emerg] directive "location" has no opening "{" in /usr/local/nginx/conf/vhost/lisiqiong.ttyun.com.conf:11Feb16 14:26:35Dev_wechat nginx: [FAILED]

Feb16 14:26:35 Dev_wechat systemd: nginx.service: control process exited, code=exited status=1Feb16 14:26:35Dev_wechat systemd: Unit nginx.service entered failed state.

Feb16 14:26:35Dev_wechat systemd: nginx.service failed.

Feb16 14:26:35 Dev_wechat root: [euid=root]:root pts/0 2017-02-16 09:28 (172.168.6.252):[/usr/local/nginx/conf/vhost]2017-02-16 14:26:34 root service nginx restart

仔细查看日志发现错误报在/usr/local/nginx/conf/vhost/lisiqiong.ttyun.com.conf这个配置文件的11行代码

我靠在看前面的nginx配置发现11就是这行代码

location ~ .php${

你会发现nginx配置中{前面是需要空格的,我晕,最后重启

service nginx restart

一切ok了,就是这么简单,这个日志真的是太有用了,很适合调试服务懵逼时使用