Package org.logevents.observers.file
Class FilenameFormatter
- java.lang.Object
-
- org.logevents.observers.file.FilenameFormatter
-
public class FilenameFormatter extends Object
Creates, parses and scans for file names matching a specified pattern, such aslogs/%mdc{tenant:-common}/%date{YYYY-'w'WW}/%application-%EE.log
, which would expand tologs/example.org/2020-W01/myapplication-Mon.log
if theMDC
variable "tenant" was "example.org" and the date 2019/12/30 (which was the first week of the year 2020).The following conversion words are supported in the filename:
-
%date
: The date and time of the log event. Optionally supports a date formatting pattern fromDateTimeFormatter.ofPattern(java.lang.String)
e.g. %date{DD-MMM HH:mm:ss}. Default format isyyyy-MM-dd HH:mm:ss.SSS
. %marker[{defaultValue}]
:Marker
(if any)-
%mdc{key:-default}
: the specifiedMDC
variable or default value if not set %application
: The value ofConfiguration.getApplicationName()
%node
: The value ofConfiguration.getNodeName()
()}
-
-
-
Constructor Summary
Constructors Constructor Description FilenameFormatter(String filenamePattern)
FilenameFormatter(String filenamePattern, Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
findFileNames()
String
format(LogEvent logEvent)
String
generateName(ZonedDateTime fileTime)
String
generateName(org.logevents.observers.file.FileInfo fileInfo)
org.logevents.observers.file.FileInfo
parse(String filename)
String
toString()
-
-
-
Constructor Detail
-
FilenameFormatter
public FilenameFormatter(String filenamePattern)
-
FilenameFormatter
public FilenameFormatter(String filenamePattern, Configuration configuration)
-
-
Method Detail
-
generateName
public String generateName(org.logevents.observers.file.FileInfo fileInfo)
-
generateName
public String generateName(ZonedDateTime fileTime)
-
parse
public org.logevents.observers.file.FileInfo parse(String filename)
-
-