我有一个日志文件及其第一行:**99.91.220.138 - - [05/Oct/2015:06:37:26 +0300] "GET /R/0A/ID_0000013091.ism/QualityLevels(1469889)/Fragments(video=14795200000) HTTP/1.1" 200 658377 "-" "Firefox/1.5" "-" rt=0.000 ut="-" cs=HIT**
我想分开这一行并打印它们:
事件时间:[05 / Oct / 2015:06:37:26 +0300]
请求方法:获取
内容地址:/R/0A/ID_0000013091.ism/QualityLevels(1469889)/Fragments(video=14795200000)
内容名称:ID_0000013091
内容比特率i :QualityLevels( 1469889 )我尝试只写1400000
内容类型:片段(视频 = 14795200000)视频或音频
HTTP状态:200
发送的字节总数:658377
用户代理: Firefox / 1.5
阅读此信息后,我会将它们插入mssql数据库。
我如何打印它们?
我尝试String pattern = "\\[([\\w:/]+\\s[+\\-]\\d{4})\\] (\\S) \\[(\\w+) ([\\d.]+) ([\\d.]+) (\\w+) (\\w+.*)\\] (\\w.*?\\d{3}) ([\\d.]+) \"([^\"]*)\" \"([^\"]*)\" (\\S) (\\w+) (.*)";
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(line);
if (m.find( )) {
System.out.println("String: " + m.group(0) );
System.out.println("IP: " + m.group(1) );
System.out.println("Event time: " + m.group(2) );
System.out.println("Request Method: " + m.group(3) );
System.out.println("Content adress: : " + m.group(4) );
System.out.println("Content name: " + m.group(5) );
System.out.println("Content bitrate i: " + m.group(6) );
System.out.println("Content type: " + m.group(7) );
System.out.println("HTTP Status: " + m.group(8) );
System.out.println("Total sent Bytes: " + m.group(9) );
System.out.println("User Agent: " + m.group(10) );
System.out.println("Cache Status: " + m.group(11) );
} else {
System.out.println("NO MATCH");
}
但这对我没有帮助。我的模式或其他错误在哪里?