Class DateLookup

  • All Implemented Interfaces:
    StrLookup

    @Plugin(name="date",
            category="Lookup")
    public class DateLookup
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      DateLookup()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String formatDate​(long date, java.lang.String format)  
      java.lang.String lookup​(java.lang.String key)
      Looks up the current date.
      java.lang.String lookup​(LogEvent event, java.lang.String key)
      Looks up d the current date or the date in the LogEvent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final Logger LOGGER
      • LOOKUP

        private static final Marker LOOKUP
    • Constructor Detail

      • DateLookup

        public DateLookup()
    • Method Detail

      • lookup

        public java.lang.String lookup​(java.lang.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 java.lang.String lookup​(LogEvent event,
                                       java.lang.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.
      • formatDate

        private java.lang.String formatDate​(long date,
                                            java.lang.String format)