如何根据日志来分析用户行为?


如下所述,是我目前上线的一个移动应用的记录:


 json


 --------------------------------------
七月 20, 2015 11:23:28 下午 org.apache.cxf.interceptor.LoggingInInterceptor
信息: Inbound Message
----------------------------
ID: 48
Address: http://192.168.1.189:8088/travelman/rest/user/login
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: multipart/form-data; boundary=Boundary+2E7AAA12C3FA4768
Headers: {Accept=[*/*], accept-encoding=[gzip, deflate], Accept-Language=[zh-Hans;q=1], connection=[keep-alive], Content-Length=[163], content-type=[multipart/form-data; boundary=Boundary+2E7AAA12C3FA4768], Host=[192.168.1.189:8088], User-Agent=[TravelMan/0.2.2.1 (iPhone; iOS 8.4; Scale/2.00)]}
Payload: --Boundary+2E7AAA12C3FA4768
Content-Disposition: form-data; name="record"
{"loginNumber":"18392584399","password":"12p4rc4n8oyv34mri124689u896575690#$E%^TY*(J)_Ji0909090909mcwopcfi9buy68j"}
--Boundary+2E7AAA12C3FA4768--

--------------------------------------
七月 20, 2015 11:24:12 下午 org.apache.cxf.interceptor.LoggingInInterceptor
信息: Inbound Message
----------------------------
ID: 91
Address: http://192.168.1.189:8088/travelman/rest/travelnote/create
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: multipart/form-data; boundary=Boundary+7B788126F1DC5BFD
Headers: {Accept=[*/*], accept-encoding=[gzip, deflate], Accept-Language=[zh-Hans;q=1, en;q=0.9, fr;q=0.8, de;q=0.7, ja;q=0.6, nl;q=0.5], connection=[keep-alive], Content-Length=[355], content-type=[multipart/form-data; boundary=Boundary+7B788126F1DC5BFD], Host=[192.168.1.189:8088], User-Agent=[TravelMan/0.2.2.1 (iPhone; iOS 7.0.4; Scale/2.00)]}
Payload: --Boundary+7B788126F1DC5BFD
Content-Disposition: form-data; name="record"

{"cityCode":"","cityName":"","userId":"75376449","createTime":"","collectCount":"0","tips":"","isShared":true,"placeCount":"0","tag":"","userName":"mimicky","travelNotePhotos":[],"travelNoteId":"","monthIndex":"","money":"","isCollected":false}
--Boundary+7B788126F1DC5BFD--

--------------------------------------
七月 20, 2015 11:26:54 下午 org.apache.cxf.interceptor.LoggingInInterceptor
信息: Inbound Message
----------------------------
ID: 107
Address: http://192.168.1.189:8088/travelman/rest/user/sharePhoto/create
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: multipart/form-data; boundary=Boundary+004508D37AC42838
Headers: {Accept=[*/*], accept-encoding=[gzip, deflate], Accept-Language=[zh-Hans;q=1], connection=[keep-alive], Content-Length=[482], content-type=[multipart/form-data; boundary=Boundary+004508D37AC42838], Host=[192.168.1.189:8088], User-Agent=[TravelMan/0.2.2.1 (iPhone; iOS 8.4; Scale/2.00)]}
Payload: --Boundary+004508D37AC42838
Content-Disposition: form-data; name="record"

{"placeName":"北京¸‚","type":"FOOD","userId":"69617238","score":"5","isShare":true,"commentCount":0,"supportCount":0,"placeId":"029","items":[{"supportCount":0,"comments":null,"commentCount":0,"image":"69617238201527201527452860.png"},{"supportCount":0,"comments":null,"commentCount":0,"image":"69617238201527201527453280.png"}],"placeType":"CITY","isCollected":false}
--Boundary+004508D37AC42838--
--------------------------------------

日志记录是使用apache的 cxf自带的记录工具。
比如我要统计哪个URL访问最多,在发布一个sharePhoto的时候能够提取出城市来计算哪个城市发布的照片最多。

用户每个接口传进来的json都不一样。对于日志处理,是不是先要将日志格式统一?或者说干啥的?

目前我的日志就是存储在一个文本文件中间的。
请问在处理日志之前,我应该做哪些准备工作?有什么开源框架可以使用?
我在日志处理这一块完全没有经验。所以问的问题可以比较宽泛一些。希望大神能够解答。

日志

同德第六虎Y震 9 years, 10 months ago

我觉得你可以把对你有用的日志按照某种格式(你好处理的格式,比如json,或者直接按\t分割)输出到一个特定的文件里面,便于分析。

如果非得和系统的日志一起输出到一个文件里面的话,可以用正则表达式去匹配你感兴趣的行,然后再去解析这行里面包含的数据,不推荐使用这种方式,比较麻烦,而且可读性也会很差,也不好维护,当有需求时也不能扩展。

小鼻涕噶儿 answered 9 years, 10 months ago

Your Answer