docker知识: docker日志

本文详细介绍Docker日志管理的实用选项,包括显示详细信息、跟随日志输出、显示时间戳、查看指定行数及时间范围内的日志,帮助读者掌握Docker日志的高效查看方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

docker知识: docker日志

Options:
      --details        Show extra details provided to logs
  -f, --follow         Follow log output
      --help           Print usage
      --since string   Show logs since timestamp
      --tail string    Number of lines to show from the end of the logs (default "all")
  -t, --timestamps     Show timestamps

显示时间戳

docker logs -f -t  insepctTomcat_1
2019-03-22T08:57:41.961027000Z     at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
2019-03-22T08:57:41.961817000Z     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
2019-03-22T08:57:41.962603000Z     at com.sun.proxy.$Proxy24.selectOne(Unknown Source)
2019-03-22T08:57:41.963379000Z     at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
2019-03-22T08:57:41.964448000Z     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83)
2019-03-22T08:57:41.965432000Z     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
2019-03-22T08:57:41.966337000Z     at com.sun.proxy.$Proxy33.getExitInfoByExitId(Unknown Source)
2019-03-22T08:57:41.967198000Z     at com.sgx.inspect.engine.service.impl.InputServiceImpl.getExitInfoByExitId(InputServiceImpl.java:64)
2019-03-22T08:57:41.968018000Z     at com.sgx.inspect.engine.CheckEngine.additionCheck(CheckEngine.java:180)
2019-03-22T08:57:41.968876000Z     at com.sgx.inspect.sup.service.SupCommonService.netCenterAutoIssueSupCheckResult(SupCommonService.java:48)

查看尾n行

docker logs -f --tail 10  insepctTomcat_1
    at com.sgx.inspect.engine.CheckEngine.additionCheck(CheckEngine.java:180)
    at com.sgx.inspect.sup.service.SupCommonService.netCenterAutoIssueSupCheckResult(SupCommonService.java:48)
    at com.sgx.inspect.engine.schedule.SupSchedule.lambda$run$0(SupSchedule.java:97)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at com.sgx.inspect.engine.schedule.SupSchedule.run(SupSchedule.java:94)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)

查看since多长时间的日志
相对时间

docker logs -f  -t --since 2019-03-22T09:30:12    insepctTomcat_1
2019-03-22T09:30:12.241144000Z [com.sgx.inspect.engine.schedule.SupSchedule] - 调度 30 天前的数据
2019-03-22T09:30:12.242340000Z [com.sgx.inspect.engine.schedule.SupSchedule] - 调度 CheckRecordId:201912301132060app21104746
2019-03-22T09:30:12.259525000Z [com.sgx.inspect.sup.service.SupCommonService] - checkRecordId:201912301132060app21104746
2019-03-22T09:30:12.261768000Z org.springframework.jdbc.BadSqlGrammarException:
2019-03-22T09:30:12.265476000Z ### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Unknown column 'ExitStation' in 'field list'
2019-03-22T09:30:12.266489000Z ### The error may exist in URL [jar:file:/usr/local/tomcat/webapps/prealtruckInspect/WEB-INF/lib/inspect-1.0.jar!/com/sgx/inspect/engine/dao/insp/mapping/InputFromCheckSysMapper.xml]

查看since多长时间的日志
绝对时间

docker logs -f  -t --since 1s    insepctTomcat_1
2019-03-22T09:30:12.241144000Z [com.sgx.inspect.engine.schedule.SupSchedule] - 调度 30 天前的数据
2019-03-22T09:30:12.242340000Z [com.sgx.inspect.engine.schedule.SupSchedule] - 调度 CheckRecordId:201912301132060app21104746
2019-03-22T09:30:12.259525000Z [com.sgx.inspect.sup.service.SupCommonService] - checkRecordId:201912301132060app21104746
2019-03-22T09:30:12.261768000Z org.springframework.jdbc.BadSqlGrammarException:
2019-03-22T09:30:12.265476000Z ### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Unknown column 'ExitStation' in 'field list'
2019-03-22T09:30:12.266489000Z ### The error may exist in URL [jar:file:/usr/local/tomcat/webapps/prealtruckInspect/WEB-INF/lib/inspect-1.0.jar!/com/sgx/inspect/engine/dao/insp/mapping/InputFromCheckSysMapper.xml]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值