Class DateLookup

java.lang.Object
org.apache.logging.log4j.core.lookup.DateLookup
All Implemented Interfaces:
StrLookup

@Plugin(name="date", category="Lookup") public class DateLookup extends Object implements StrLookup
Formats the current date or the date in the LogEvent. The "key" is used as the format String, following the java.text.SimpleDateFormat date and time pattern strings.
  • Constructor Details

    • DateLookup

      public DateLookup()
  • Method Details

    • lookup

      public String lookup(String key)
      Looks up the current date.
      Specified by:
      lookup in interface StrLookup
      Parameters:
      key - the format to use. If null, the default DateFormat will be used.
      Returns:
      The formatted current date, never null.
    • lookup

      public String lookup(LogEvent event, String key)
      Looks up d the current date or the date in the LogEvent.
      Specified by:
      lookup in interface StrLookup
      Parameters:
      event - The LogEvent for which the date is returned. If null, current date is returned.
      key - the format to use. If null, the default DateFormat will be used.
      Returns:
      The formatted date, never null.