第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

老師你的 nginx 日志規(guī)則是什么

我的是nginx默認(rèn)的日志格式? ??

log_format??main??'$remote_addr?-?$remote_user?[$time_local]?"$request"?'
??????????????????'$status?$body_bytes_sent?"$http_referer"?'??????????????????????
??????????????????'"$http_user_agent"?"$http_x_forwarded_for"';


正在回答

1 回答

//nginx規(guī)則
'$remote_addr\t$http_x_forwarded_for\t$request\t$status\t$body_bytes_sent\t$bytes_sent\t$http_user_agent\t$request_length\t$request_time\t$time_local\t$upstream_response_time'
/**
???解析模塊
*/
func?(l?*LogProcess)?Process()?{

???/*rege?:=?regexp.MustCompile(`([\d\.]+)\s+([^?\[]+)\s+([^?\[]+)\s+\[([^\]]+)\]\s+([a-z]+)\s+\"([^"]+)\"\s+(\d{3})\s+(
\d+)\s+\"([^"]+)\"\s+\"(.*?)\"\s+\"([\d\.-]+)\"\s+([\d\.-]+)\s+([d\.-]+)`)?//解析正則表達(dá)式*/

???//循環(huán)解析
???loc,?_?:=?time.LoadLocation("Asia/Shanghai");
???for?v?:=?range?l.rc??{
??????//res?:=?rege.FindStringSubmatch(string(v)?)
??????fmt.Println(string(v))
??????res?:=?strings.Split(string(v),?"\t")
??????if?len(res)?!=?11?{????//匹配失敗
?????????log.Println("rege.FindStringSubmatch?fail:?",?string(v),?len(res))????//寫日志
?????????continue
??????}
??????message?:=?&Message?{}
??????//時間
??????theTime,?err?:=?time.ParseInLocation("02/Jan/2006:15:04:05?+0800",?res[9],?loc)????//解析時間
??????if?err?!=?nil?{
?????????log.Println("time.ParseInLocation?fail:?",?err.Error(),?res[9])????//寫日志
?????????continue
??????}
??????time?:=?theTime.Unix()
??????message.TimeLocal?=?time

??????bytesSent,?_?:=?strconv.Atoi(res[5])????????????//字符串轉(zhuǎn)?int
??????message.BytesSent?=?bytesSent

??????//"POST?/API/COURSE/INDEX?HTTP/1.1"
??????resSli?:=?strings.Split(res[2],?"?")?????????//字符串分割
??????if?len(resSli)?!=?3?{
?????????log.Println("strings.Split?fail",?res[2])??//寫日志
?????????continue
??????}
??????message.Method?=?resSli[0]

??????resUrl,?err?:=?url.Parse(resSli[1])
??????if?err?!=?nil?{
?????????log.Println("url.Parse?fail",?err.Error(),resSli[1])???//寫日志
?????????continue
??????}
??????message.Path?=?resUrl.Path

??????message.Scheme?=?resSli[2]

??????message.Status?=?res[3]

??????upstreamTime,?_?:=?strconv.ParseFloat(res[10],?64)
??????message.UpstreamTime?=?upstreamTime

??????requestTime,?_?:=?strconv.ParseFloat(res[8],?64)
??????message.RequestTime?=?requestTime

??????l.wc?<-?message
???}
}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

老師你的 nginx 日志規(guī)則是什么

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號