xxl-job-admin.log示例文件
2021-04-27 05:02:59,572 INFO [http-nio-8800-exec-8] o.a.coyote.http11.Http11Processor [DirectJDKLog.java : 175] Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x000x00i0x010x000x00e0x030x03U0x1c0xa70xe4random1random2random3random40x000x000x0c0x00/0x000x0a0x000x130x0090x000x040x000xff0x010x000x0000x000x0d0x00,0x00*0x000x010x000x030x000x020x060x010x060x030x060x020x020x010x020x030x020x020x030x010x030x030x030x020x040x010x040x030x040x020x010x010x010x030x010x020x050x010x050x030x05...]. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:417)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
一:grep基本用法
grep "match_pattern" file_1 file_2 :在多个文件中查找
grep -v "match_pattern" filename :输出除之外的所有行
grep -E "[1-9]+" :使用正则表达式 -E选项
grep -o -E "[a-z]+\." line :只输出匹配到的内容选项
grep -c "match_pattern" filename :统计文本或者文件中包含匹配字符串的行数 -c选项
grep "match_pattern" -n filename :输出包含匹配字符串的行数
grep "2019-08-06 22" filename :查看2019-08-06 22点这一个小时以内的日志信息
cat filename |grep -n "2019-08-28 11:45" :读取文件外加过滤条件
grep "test" -A 10 filename|tail -n 11 :查看日志最后一次出现关键字"test"的日志记录
-a :将 binary 文件以 text 文件的方式搜寻数据
-c :计算找到 ‘搜寻字符串’ 的次数
-i :忽略大小写的不同,所以大小写视为相同
-n :顺便输出行号
-v :反向选择,亦即显示出没有 ‘搜寻字符串’ 内容的那一行!
–color=auto :可以将找到的关键词部分加上颜色的显示喔!
1.在xxl-job-admin.log文件中,筛选包含Error的行
grep Error xxl-job-admin.log
返回:
[root@hc xxl-job]# grep Error xxl-job-admin.log
2021-04-27 05:02:59,572 INFO [http-nio-8800-exec-8] o.a.coyote.http11.Http11Processor [DirectJDKLog.java : 175] Error parsing HTTP request header
2.在xxl-job-admin.log文件中,筛选不包含Error的行,加上-v参数即可:
grep -v Error xxl-job-admin.log
[root@hc xxl-job]# grep -v Error xxl-job-admin.log
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x000x00i0x010x000x00e0x030x03U0x1c0xa70xe4random1random2random3random40x000x000x0c0x00/0x000x0a0x000x130x0090x000x040x000xff0x010x000x0000x000x0d0x00,0x00*0x000x010x000x030x000x020x060x010x060x030x060x020x020x010x020x030x020x020x030x010x030x030x030x020x040x010x040x030x040x020x010x010x010x030x010x020x050x010x050x030x05...]. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:417)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
3.查看2021-04-27 14点这一个小时以内的日志信息
grep "2021-04-27 14" nacos.log
[root@hc logs]# grep "2021-04-27 14" nacos.log
2021-04-27 14:04:33,952 WARN clearConfigHistory start
2021-04-27 14:04:35,151 INFO [capacityManagement] start correct usage
2021-04-27 14:04:35,168 INFO [capacityManagement] end correct usage, cost: 0s
2021-04-27 14:14:33,964 WARN clearConfigHistory start
2021-04-27 14:14:35,168 INFO [capacityManagement] start correct usage
2021-04-27 14:14:35,185 INFO [capacityManagement] end correct usage, cost: 0s
2021-04-27 14:24:33,977 WARN clearConfigHistory start
2021-04-27 14:24:35,185 INFO [capacityManagement] start correct usage
2021-04-27 14:24:35,206 INFO [capacityManagement] end correct usage, cost: 0s
2021-04-27 14:34:33,987 WARN clearConfigHistory start
2021-04-27 14:34:35,206 INFO [capacityManagement] start correct usage
2021-04-27 14:34:35,222 INFO [capacityManagement] end correct usage, cost: 0s
2021-04-27 14:44:34,000 WARN clearConfigHistory start
2021-04-27 14:44:35,222 INFO [capacityManagement] start correct usage
2021-04-27 14:44:35,238 INFO [capacityManagement] end correct usage, cost: 0s
2021-04-27 14:54:34,013 WARN clearConfigHistory start
2021-04-27 14:54:35,238 INFO [capacityManagement] start correct usage
2021-04-27 14:54:35,259 INFO [capacityManagement] end correct usage, cost: 0s
4.grep -c “match_pattern” filename :统计文本或者文件中包含匹配字符串的行数 -c选项
grep -c "WARN" nacos.log
[root@hc logs]# grep -c "WARN" nacos.log
90
5.cat filename |grep -n “2019-08-28 11:45” :读取文件外加过滤条件
[root@hc logs]# cat nacos.log |grep -n "2021-04-27 15"
541:2021-04-27 15:04:34,025 WARN clearConfigHistory start
543:2021-04-27 15:04:35,259 INFO [capacityManagement] start correct usage
545:2021-04-27 15:04:35,268 INFO [capacityManagement] end correct usage, cost: 0s
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/65799.html