閱讀174 返回首頁    go iPhone_iPad_Mac_手機_平板_蘋果apple


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)_用戶指南_日誌服務-阿裏雲