阅读174 返回首页    go 微信


Logtail日期格式__logtail(Agent)_用户指南_日志服务-阿里云

正如日志服务核心概念中所描述,每条日志服务日志都必须包括该日志发生的时间戳信息。Logtail接入服务在采集用户日志文件中的日志数据,必须提取该条日志中时间戳字符串并把它解析为时间戳。因此,Logtail需要用户指定其日志的时间戳格式帮助解析。

Linux平台下的Logtail支持strftime函数提供的所有时间格式。 只需要用户的日志时间戳字符串能够被该函数定义的日志格式所表达,即可以被Logtail解析并使用。

现实环境中的日志时间戳字符串格式非常多样化,为方便用户配置,Logtail支持的常见日志时间格式如下:

支持格式 格式意义 示例
%a locale’s abbreviated weekday name 例如:Fri
%A locale’s full weekday name 例如:Friday
%b locale’s abbreviated month name 例如:Jan
%B locale’s full month name 例如:January
%d day of the month as a decimal number [1,31] 例如:7, 31
%h same as %b 例如:Jan
%H hour (24-hour clock) as a decimal number 例如:22
%I hour (12-hour clock) as a decimal number 例如:11
%m month as a decimal number 例如:08
%M minute as a decimal number [00,59] 例如:59
%n newline character 换行符
%p locale’s equivalent of either a.m. or p.m 例如:AM/PM
%r time in a.m. and p.m. notation (%I:%M:%S %p) 例如:11:59:59 AM
%R time in 24 hour notation (%H:%M) 例如:23:59
%S second as a decimal number[00,59] 例如:59
%t tab character TAB符
%y year without century as a decimal number [00,99] 例如:04,98
%Y year with century as a decimal number 例如:2004,1998
%z timezone name or abbreviation, or by no bytes if no timezone information exists 例如:-07:00, +0800
%C century number as a decimal number [00-99] 例如:16
%e the day of the month as a decimal number [1,31]; a single digit is preceded by a space{color}
%j day of the year as a decimal number [001,366] 例如:365
%u weekday as a decimal number [1,7], with 1 representing Monday 例如:2
%U week number of the year (Sunday as the first day of the week) as a decimal number [00,53] 例如:23
%V week number of the year (Monday as the first day of the week) as a decimal number [01,53] 例如:24
%w weekday as a decimal number [0,6], with 0 representing Sunday{ 例如:5
%W week number of the year (Monday as the first day of the week) as a decimal number [00,53] 例如:23
%c locale’s appropriate date and time representation 需要指定长日期、短日期等更多信息,可以考虑用上面支持的格式更精确表达
%x locale’s appropriate date representation 需要指定长日期、短日期等更多信息,可以考虑用上面支持的格式更精确表达
%X locale’s appropriate time representation 需要指定长日期、短日期等更多信息,可以考虑用上面支持的格式更精确表达
%s unix 时间戳 例如:1476187251

最后更新:2016-10-11 20:01:33

  上一篇:go 安装Logtail__logtail(Agent)_用户指南_日志服务-阿里云
  下一篇:go Logtail自定义机器标识管理__logtail(Agent)_用户指南_日志服务-阿里云