Class AWSLambdaLoggerFactory

  • All Implemented Interfaces:
    ILoggerFactory

    public class AWSLambdaLoggerFactory
    extends Object
    implements ILoggerFactory
    Responsible for building Logger using the AWSLambdaLogger implementation.

    The configuration is similar to SLF4J Simple.

    It looks for the lambda-logger.properties resource and read properties:

    • dateTimeFormat - The date and time format to be used in the output messages. The pattern describing the date and time format is defined by SimpleDateFormat. If the format is not specified or is invalid, the number of milliseconds since start up will be output.
    • defaultLogLevel - Default log level for all instances of LambdaLogger. Must be one of (trace, debug, info, warn, error), a value is case-insensitive. If not specified, defaults to info.
    • levelInBrackets - Should the level string be output in brackets? Defaults to false.
    • log.a.b.c - Logging detail level for a LambdaLogger instance named a.b.c
    • requestId - Set the context name of AWS request ID. Defaults to AWS_REQUEST_ID.
    • showDateTime - Set to true if you want the current date and time to be included in output messages. Defaults to false.
    • showLogName - Set to true if you want the Logger instance name to be included in output messages. Defaults to true.
    • showShortLogName - Set to true if you want the last component of the name to be included in output messages. Defaults to false.
    • showThreadId - If you would like to output the current thread id, then set to true. Defaults to false.
    • showThreadName - Set to true if you want to output the current thread name. Defaults to false.

    The environment variables overrides the properties: LOG_AWS_REQUEST_ID, LOG_DATE_TIME_FORMAT, LOG_DEFAULT_LEVEL, LOG_LEVEL_IN_BRACKETS, LOG_SHOW_DATE_TIME, LOG_SHOW_NAME, LOG_SHOW_SHORT_NAME, LOG_SHOW_THREAD_ID, LOG_SHOW_THREAD_NAME.

    Fine-grained configuration with markers

    The AWS Lambda Logger supports markers since v2.0.0. The log level (default or detail) can have some log level and each level can have some markers.

    Example:

    
     log.org.test.Class=warn,info@iAmMarker,trace@important:notify-admin
     
    The logger for org.test.Class has the common warn log level. Also, it has additional levels info with the marker iAmMarker and trace with markers important and notify-admin.

    You can customize level and marker separators with properties logLevelSeparator and markerSeparator. Remember that separators are not a single characters but regular expressions. The environment variables are LOG_LEVEL_SEPARATOR and LOG_MARKER_SEPARATOR accordingly.

    Example:

    
     log.org.test.Class=warn  info@iAmMarker trace@important|notify-admin
     # multi-space
     logLevelSeparator=\\s+
     # single pipe symbol
     markerSeparator=\\|
     
    See Also:
    AWSLambdaLoggerConfigurationProperty
    • Constructor Detail

      • AWSLambdaLoggerFactory

        public AWSLambdaLoggerFactory()
        AWS Lambda Logger Factory.

        Looking for a configuration file lambda-logger.properties.