公司nginx的 access.log 和 error.log

access.log

使用配置方式:

# 日志格式
    log_format main '$time_local|10.4.24.116|$request|$status|'
                    '$remote_user|$remote_addr|$http_user_agent|$http_referer|$host|'
                    '$bytes_sent|$request_time|$upstream_response_time|$upstream_addr|'
                    '$connection|$connection_requests|$upstream_http_content_type|$upstream_http_content_disposition|$uuid';

    access_log  logs/access.log  main;      #設置訪問日志打印路徑

日志實例:

01/Aug/2017:12:01:32 +0800|10.4.24.116|GET /images/logo/new-logo2.ico HTTP/1.1|200|
-|111.202.5.249|Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36|http://crm111.chime.me/admin/home|crmtest.chime.me|
15707|0.000|-|-|
4909722|3|-|-|f3a50c3e-be90-4693-9d7c-c414d825fd22

日志參數:

參數 說明 實例
$time_local 訪問的時間和時區(qū) 01/Aug/2017:12:01:32 +0800
$request 請求的URL和HTTP信息 GET /images/logo/new-logo2.ico HTTP/1.1
$status 請求的狀態(tài) 200
$remote_user 客戶端用戶名稱 -
$remote_addr 客戶端地址 111.202.5.249
$http_user_agent 用戶終端瀏覽器等信息 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
$http_referer url跳轉來源 http://crm111.chime.me/admin/home
$host 域名 crmtest.chime.me
$bytes_send 發(fā)送給客戶端的字節(jié)數 15707
$request_time 請求處理時間 0.000
$upstream_response_time 服務主機的響應時間 -
$upstream_addr 服務主機的地址 -
$connection 當前的連接序號 4909722
$connection_requests 當前的連接數量 3
$upstream_http_content_type 響應的內容格式,如:text/html;charset=UTF-8 -
$upstream_http_content_disposition 不明 -
$uuid perl_set $uuid 'sub {$ug = new Data::UUID;$str = $ug->create_str();return $str;}'; 用來唯一標示一個請求連接

error.log

2017/08/01 18:29:43 [info] 233168#0: *4925140 client 10.2.203.101 closed keepalive connection
2017/08/01 18:29:43 [info] 233168#0: *4925138 client 10.2.203.101 closed keepalive connection
2017/08/01 18:29:43 [info] 233168#0: *4925133 client 10.2.203.101 closed keepalive connection
類型 作用 實例
時間 2017/08/01 18:29:43
日志等級 [info]
錯誤信息 233168#0: *4925133 client 10.2.203.101 closed keepalive connection

log4j

access.log

log4j的access日志:

2017-08-01-16:24:35 |1501575875145|111.202.5.248|10000000514|Xiaoxuexuexuexue Wang|
crm111.chime.me|/admin/lead/timeline/all|
https://crm111.chime.me/admin/lead/detail?leadId=671013327073323&pos=0&normal=false&type=all&stageId=&filter=%7B%7D&filterId=&curPage=0&pageSize=50&sortType=&desc=&groupId=0|
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36|web|
{"pageNo":"0","pageSize":"20","agentActionLabel":"-1","leadId":"671013327073323","_":"1501575891980"}|
d4b671b5-85c0-4fa3-90a4-d8e243a04aed 
參數 說明 實例
timestamp 時間戳 2017-08-01-16:24:35
userId 用戶ID 1501575875145
remoteIp 用戶的ip 111.202.5.248
username 用戶的name Xiaoxuexuexuexue Wang
domain 域名 crm111.chime.me
uri uri /admin/lead/timeline/all
refer 哪個頁面鏈接過來的 https://crm111.chime.me/admin/lead/detail?leadId=671013327073323&pos=0&normal=false&type=all&stageId=&filter=%7B%7D&filterId=&curPage=0&pageSize=50&sortType=&desc=&groupId=0
userAgent 用戶終端瀏覽器信息 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
termailType 3g:mobile web:other web
param json 請求參數信息 {"pageNo":"0","pageSize":"20","agentActionLabel":"-1","leadId":"671013327073323","_":"1501575891980"}
requestId 用于定位access log與業(yè)務log d4b671b5-85c0-4fa3-90a4-d8e243a04aed

homethy_out.log

配置

2017-08-01 16:36:25|1501576585413|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(CrmWebBusiness.setUserIdFromRequest:199)|[setUserIdFromRequest] ticketRedisKey: b372bdcdddb0cff84174a0bdcc63f39c_crm111.chime.me, userId: 501581213053651
2017-08-01 16:36:25|1501576585413|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(TicketManagerServiceImpl.checkTicket:55)|[checkTicket] business: CRMWEB, BusinessBase [userId=501581213053651, maxAge=2592000, path=/, domain=chime.me, allowMultiLogin=true, keepLogin=true]
2017-08-01 16:36:25|1501576585414|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(CrmWebBusiness.checkTicket:103)|[checkTicket] check ticket success, userId: 501581213053651, serverName: crm111.chime.me
2017-08-01 16:36:25|1501576585415|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(CrmWebBusiness.setUserIdFromRequest:199)|[setUserIdFromRequest] ticketRedisKey: b372bdcdddb0cff84174a0bdcc63f39c_crm111.chime.me, userId: 501581213053651
2017-08-01 16:36:25|1501576585415|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(TicketManagerServiceImpl.getUser:107)|[getUser] business: CRMWEB, BusinessBase [userId=501581213053651, maxAge=2592000, path=/, domain=chime.me, allowMultiLogin=true, keepLogin=true]
2017-08-01 16:36:25|1501576585416|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(Slf4jLog.info:67)| user info: user: User{id=501581213053651, autoId=10000014481, account='info@chime.me', password='30:5b42403262613266303863:169cdc779cdbc38462cea51238956973f29e4854eb71327f189a84f9cf849b53', firstName='Info', lastName='Chime', phoneNumber='8719821277', phonePrivate=true, role=0, headUrl='http://image.chime.me/image/fs01/user-info/20170601/19/original_61547355077197976.jpeg', chatHeadUrl='http://image.chime.me/image/fs01/user-info/20170601/19/original_61547355077197976.jpeg', gender=0, source='Portal', inviterId='', headTx='', status=0, teamId=501581213053651, userState=32, isSystemHead=true, hasBuiltSite=false, createTime=Tue Aug 16 16:20:37 CST 2016, updateTime=null, fullName='Info Chime', roleName='agent', teamRole=0, teamRoleName='Admin', nimAccid='b0vufgib37ivn9q3yiw1_test'}
2017-08-01 16:36:25|1501576585416|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(Slf4jLog.info:67)|loginInterceptor: user info: User{id=501581213053651, autoId=10000014481, account='info@chime.me', password='30:5b42403262613266303863:169cdc779cdbc38462cea51238956973f29e4854eb71327f189a84f9cf849b53', firstName='Info', lastName='Chime', phoneNumber='8719821277', phonePrivate=true, role=0, headUrl='http://image.chime.me/image/fs01/user-info/20170601/19/original_61547355077197976.jpeg', chatHeadUrl='http://image.chime.me/image/fs01/user-info/20170601/19/original_61547355077197976.jpeg', gender=0, source='Portal', inviterId='', headTx='', status=0, teamId=501581213053651, userState=32, isSystemHead=true, hasBuiltSite=false, createTime=Tue Aug 16 16:20:37 CST 2016, updateTime=null, fullName='Info Chime', roleName='agent', teamRole=0, teamRoleName='Admin', nimAccid='b0vufgib37ivn9q3yiw1_test'}, checkPass: true
2017-08-01 16:36:25|1501576585447|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(LeadController.leadDetail:1361)|leadDetail-------------start----
2017-08-01 16:36:25|1501576585926|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(LeadController.leadDetail:1524)|userTeam teamType=======1
2017-08-01 16:36:25|1501576585926|INFO|501581213053651|bb310ae5-4fd0-475f-9686-0556989a5f36|(LeadController.leadDetail:1535)|000000000000000000000
類型 作用 實例
df.format(Long.valueOf(loggingEvent.getTimeStamp())) 格式化時間戳 2017-08-01 16:36:25
loggingEvent.getTimeStamp() 時間戳 1501576585926
loggingEvent.getLevel() 日志等級 INFO
this.getUserId(loggingEvent) 用戶id 501581213053651
this.getUniqIndex(loggingEvent) 日志時間獨特的索引 bb310ae5-4fd0-475f-9686-0556989a5f36
this.locationInfo(loggingEvent.getLocationInformation()) 日志位置信息 LeadController.leadDetail:1535)
this.throwableName(loggingEvent) 日志詳細信息 userTeam teamType=======1
this.throwableStackTrace(loggingEvent) 異常信息 exceptin異常

logs/perf/perfStats.log

perfStatus.log的信息是perf4j結合log4j來打印的,下面打印的格式是默認的。

Performance Statistics   2017-08-03 15:59:10 - 2017-08-03 15:59:20
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count
/admin/appointment/upcoming                              8.0           8           8         0.0           1
/admin/dripmail/application/list/v2                      8.0           8           8         0.0           1
/admin/group/list/simple                                 7.0           7           7         0.0           1
/admin/help/answer                                       1.0           1           1         0.0           1
/admin/help/questions                                    1.0           1           1         0.0           1
/admin/lead/emailList                                   15.0           6          24         9.0           2
/admin/lead/getScore                                    17.0          17          17         0.0           1
/admin/lead/phoneList                                   11.0           8          14         3.0           2
/admin/lead/source/list                                  7.0           7           7         0.0           1
/admin/lead/tag/list                                   110.0         110         110         0.0           1
/admin/lead/task/list/withandwithouttemplate             7.0           7           7         0.0           1
/admin/lead/timeline/all                                13.0          13          13         0.0           1
/admin/lead/timeline/manual/type/get                     7.0           7           7         0.0           1
/admin/lead/timeline/note                              185.0         185         185         0.0           1
/admin/lender/list/leadassign                           20.0          20          20         0.0           1
/admin/stage/list                                       14.0          14          14         0.0           1
/admin/team/member/list/valid                           21.0          21          21         0.0           1
/admin/virtualNumber/info                                8.0           8           8         0.0           1
/admin/vsms/template/list                              103.0         103         103         0.0           1

/admin/lead/phoneList 11.0 8 14 3.0 2

標志 含義 實例
Tag 訪問的路徑 /admin/lead/phoneList
Avg(ms) 訪問平均耗時 11.0
Min 連接訪問最小耗時 8
Max 連接訪問最大耗時 14
Std Dev 耗時的標準差
3.0
Count 訪問的次數 2

/logs/myibatis_perf/perfStats.log

Performance Statistics   2017-08-03 15:43:40 - 2017-08-03 15:43:50
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count

Performance Statistics   2017-08-03 15:43:50 - 2017-08-03 15:44:00
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count
com.homethy.payment.business.dao.contract.TeamMarketPackageDAO.getTeamMarketPackageByTeamId        26.0          26          26         0.0           1

/logs/service_perf/perfStats.log

Performance Statistics   2017-08-03 14:48:30 - 2017-08-03 14:48:40
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count
com.homethy.business.service.kafka.scheduler.LeadKafkaConsumerScheduler.consume       999.6         999        1000         0.5           5

Performance Statistics   2017-08-03 14:48:40 - 2017-08-03 14:48:50
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count
com.homethy.business.service.kafka.scheduler.LeadKafkaConsumerScheduler.consume       999.2         999        1000         0.4           5

Performance Statistics   2017-08-03 14:48:50 - 2017-08-03 14:49:00
Tag                                                  Avg(ms)         Min         Max     Std Dev       Count
com.homethy.business.service.kafka.scheduler.LeadKafkaConsumerScheduler.consume       999.0         999         999         0.0           5

/
/
/
/

\\

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • 在應用程序中添加日志記錄總的來說基于三個目的:監(jiān)視代碼中變量的變化情況,周期性的記錄到文件中供其他應用進行統(tǒng)計分析...
    時待吾閱讀 5,246評論 1 13
  • 在應用程序中添加日志記錄總的來說基于三個目的:監(jiān)視代碼中變量的變化情況,周期性的記錄到文件中供其他應用進行統(tǒng)計分析...
    時待吾閱讀 5,165評論 0 6
  • Spring Boot 參考指南 介紹 轉載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 47,290評論 6 342
  • from:https://www.cnblogs.com/ITtangtang/p/3926665.html一、L...
    enshunyan閱讀 3,421評論 0 0
  • 一、Log4j簡介 Log4j有三個主要的組件:Loggers(記錄器),Appenders (輸出源)和Layo...
    默默守護閱讀 1,985評論 2 8

友情鏈接更多精彩內容