Logtail date format

Last Updated: Jul 06, 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.

Format Meaning Example
%a locale’s abbreviated weekday name Example: Fri
%A locale’s full weekday name Example: Friday
%b locale’s abbreviated month name Example: Jan
%B locale’s full month name Example: January
%d day of the month as a decimal number [1,31] Example:7, 31
%h same as %b Example: Jan
%H hour (24-hour clock) as a decimal number Example: 22
%I hour (12-hour clock) as a decimal number Example: 11
%m month as a decimal number Example: 08
%M minute as a decimal number [00,59] Example: 59
%n newline character Linefeed
%p locale’s equivalent of either a.m. or p.m Example: AM/PM
%r time in a.m. and p.m. notation (%I:%M:%S %p) Example: 11:59:59 AM
%R time in 24 hour notation (%H:%M) Example: 23:59
%S second as a decimal number[00,59] Example: 59
%t tab character Tab character
%y year without century as a decimal number [00,99] Example: 04,98
%Y year with century as a decimal number Example: 2004,1998
%z timezone name or abbreviation, or by no bytes if no timezone information exists Example:-07:00, +0800
%C century 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}
%j day of the year as a decimal number [001,366] Example: 365
%u weekday as a decimal number [1,7], with 1 representing Monday Example: 2
%U week number of the year (Sunday as the first day of the week) as a decimal number [00,53] Example: 23
%V week 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 Sunday{ Example: 5
%W week number of the year (Monday as the first day of the week) as a decimal number [00,53] Example: 23
%c locale’s appropriate date and time representation More information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%x locale’s appropriate date representation More information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%X locale’s appropriate time representation More information, such as long date and short date, must be specified. The preceding supported formats can be used for more precise expression.
%s unix timestamp Example: 1476187251
Thank you! We've received your feedback.