Logtail date format

Last Updated: Oct 23, 2017

Each log in Log Service has a timestamp. When Logtail collects log data from files, it extracts the timestamp string of each log and parses it into a timestamp. Therefore, you need to specify a timestamp format for Logtail.

In Linux, Logtail supports all time formats provided by the strftime function. Logtail only parses and uses the timestamp strings that can be expressed in the log formats defined by the strftime function.

The timestamp strings of logs have multiple formats. To make configuration easier, Logtail supports the following common log time formats.

FormatMeaningExample
%aLocale’s abbreviated weekday nameExample: Fri
%ALocale’s full weekday nameExample: Friday
%bLocale’s abbreviated month nameExample: Jan
%BLocale’s full month nameExample: January
%dDay of the month as a decimal number [1,31]Example:7, 31
%hSame as %bExample: Jan
%HHour (24-hour clock) as a decimal numberExample: 22
%IHour (12-hour clock) as a decimal numberExample: 11
%mMonth as a decimal numberExample: 08
%M Minute as a decimal number [00,59]Example: 59
%nNewline characterLinefeed
%pLocale’s equivalent of either a.m. or p.mExample: AM/PM
%rTime in a.m. and p.m. notation (%I:%M:%S %p)Example: 11:59:59 AM
%RTime in 24 hour notation (%H:%M)Example: 23:59
%SSecond as a decimal number[00,59]Example: 59
%tTab characterTab character
%yYear without century as a decimal number [00,99]Example: 04, 98
%YYear with century as a decimal numberExample: 2004, 1998
%zTimezone name or abbreviation, or by no bytes if no timezone information existsExample:-07:00, +0800
%CCentury number as a decimal number [00-99]Example: 16
%e The day of the month as a decimal number [1,31]; a single digit is preceded by a space{color}Example: 7, 31
%jDay of the year as a decimal number [001,366]Example: 365
%uWeekday as a decimal number [1,7], with 1 representing MondayExample: 2
%UWeek number of the year (Sunday as the first day of the week) as a decimal number [00,53]Example: 23
%VWeek number of the year (Monday as the first day of the week) as a decimal number [01,53]Example: 24
%w Weekday as a decimal number [0,6], with 0 representing SundayExample: 5
%WWeek number of the year (Monday as the first day of the week) as a decimal number [00,53] Example: 23
%cLocale’s appropriate date and time representationMore information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%xLocale’s appropriate date representationMore information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%XLocale’s appropriate time representationMore information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%sUNIX timestamp Example: 1476187251
Thank you! We've received your feedback.