一、监测后台接口变化
Welcome to Alibaba Cloud Elastic Compute Service !
[root@izbp1h1b7ra872tc39i7k8z ~]# cd /usr/local -- 切换目录。
[root@izbp1h1b7ra872tc39i7k8z local]# ll
总用量 60
drwxr-xr-x 6 root root 4096 12月 26 00:18 aegis
drwxr-xr-x. 2 root root 4096 12月 5 14:04 bin
drwxr-xr-x. 2 root root 4096 11月 5 2016 etc
-rw-r--r-- 1 root root 2 12月 14 12:29 fonts.scale
drwxr-xr-x. 2 root root 4096 11月 5 2016 games
drwxr-xr-x. 2 root root 4096 12月 5 14:05 include
drwxr-xr-x. 3 root root 4096 12月 5 14:05 lib
drwxr-xr-x. 2 root root 4096 11月 5 2016 lib64
drwxr-xr-x. 2 root root 4096 11月 5 2016 libexec
drwxr-xr-x 12 root root 4096 12月 6 11:05 nginx
drwxr-xr-x. 2 root root 4096 11月 5 2016 sbin
drwxr-xr-x. 7 root root 4096 12月 5 14:04 share
drwxr-xr-x. 2 root root 4096 11月 5 2016 src
drwxr-xr-x 3 root root 4096 12月 5 13:33 ssl
drwxr-xr-x 11 root root 4096 12月 22 13:06 yizhihui
[root@izbp1h1b7ra872tc39i7k8z local]# cd yizhihui/device.joinstar.cn -- 切换到工程中
[root@izbp1h1b7ra872tc39i7k8z device.joinstar.cn]# cd logs --- 切换到工程的日志目录中。
[root@izbp1h1b7ra872tc39i7k8z logs]# ll
总用量 1404
-rw-r--r-- 1 root root 322904 12月 22 21:17 api.2017-12-22.log
-rw-r--r-- 1 root root 75950 12月 23 11:02 api.2017-12-23.log
-rw-r--r-- 1 root root 191 12月 24 10:47 api.2017-12-24.log
-rw-r--r-- 1 root root 35973 12月 25 18:29 api.2017-12-25.log
-rw-r--r-- 1 root root 156088 12月 26 20:59 api.2017-12-26.log
-rw-r--r-- 1 root root 824980 12月 27 21:45 api.2017-12-27.log
[root@izbp1h1b7ra872tc39i7k8z logs]# tail -f -n 50 api.2017-12-27.log ---查看日志,监测接口的变化。
[2017-12-27 21:43:50.030][DEBUG]dao.com.yizhihui.mapper.VersionUpdateMapper.insert:145 ==> Preparing: INSERT INTO version_update ( Id,version,address,version_flag,create_time,app_name ) VALUES( ?,?,?,?,?,? )
[2017-12-27 21:43:50.031][DEBUG]dao.com.yizhihui.mapper.VersionUpdateMapper.insert:145 ==> Parameters: null, 1.1.1.001(String), http://116.62.160.122/calibration/JoinStar.API.dll(String), null, 2017-12-27 21:43:50.029(Timestamp), js上位机(String)
[2017-12-27 21:43:50.039][DEBUG]dao.com.yizhihui.mapper.VersionUpdateMapper.insert:145 <== Updates: 1
[2017-12-27 21:43:50.040][DEBUG]dao.com.yizhihui.mapper.VersionUpdateMapper.insert!selectKey:145 ==> Executing: SELECT LAST_INSERT_ID()
[2017-12-27 21:43:50.043][DEBUG]dao.com.yizhihui.mapper.VersionUpdateMapper.insert!selectKey:145 <== Total: 1
[2017-12-27 21:44:03.854][INFO]com.yizhihui.common.RestInterceptor:30 调用接口:method=yzh.Upload.versionrelease,params={"method":["yzh.Upload.versionrelease"]}
[2017-12-27 21:44:03.856][DEBUG]dao.com.yizhihui.mapper.VersionReleaseMapper.insert:145 ==> Preparing: INSERT INTO version_release ( id,device_sn,version,version_update_id,create_time ) VALUES( ?,?,?,?,? )
也可以用:
grep 关键字 文件名 --过滤关键字查询;若关键之中有空格,则要用单引号将整个关键字引起。
二、日志查询
1. 切换到工程的后台日志目录下: cd /usr/local/yizhijie/ciq.yizhijie.com/logs
2. 查询所有文件: ll
3. 查询关键字,在某个日志文件下。如:grep 调用接口 app.2017-06-01.log
查找某时间段使用情况: grep '2017-06-01 09:53' app.2017-06-01.log
三、跨域问题
解决方法: nginx服务器上的配置文件。
server {
listen 80;
server_name file.yizhijie.com;
location /
{
root /xxxxxxxxx-upload/;
add_header 'Access-Control-Allow-Origin' '*';
#
# Om nom nom cookies
#
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
}