Class AWSLambdaLoggerFactory
- java.lang.Object
-
- uk.bot_by.aws_lambda.slf4j.AWSLambdaLoggerFactory
-
- All Implemented Interfaces:
ILoggerFactory
public class AWSLambdaLoggerFactory extends Object implements ILoggerFactory
Responsible for buildingLoggerusing theAWSLambdaLoggerimplementation.The configuration is similar to SLF4J Simple.
It looks for the
lambda-logger.propertiesresource 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
trueif you want the current date and time to be included in output messages. Defaults tofalse. - showLogName - Set to
trueif you want the Logger instance name to be included in output messages. Defaults totrue. - showShortLogName - Set to
trueif you want the last component of the name to be included in output messages. Defaults tofalse. - showThreadId - If you would like to output the current thread id,
then set to
true. Defaults tofalse. - showThreadName - Set to
trueif you want to output the current thread name. Defaults tofalse.
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:
The logger forlog.org.test.Class=warn,info@iAmMarker,trace@important:notify-adminorg.test.Classhas 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 Summary
Constructors Constructor Description AWSLambdaLoggerFactory()AWS Lambda Logger Factory.
-
-
-
Method Detail
-
getLogger
public Logger getLogger(@NotNull @NotNull String name)
- Specified by:
getLoggerin interfaceILoggerFactory
-
-