2 Minutes To Code (β Version)

Log4j - 2 minute tutorial

Custom Pattern : Setting tokens/terms to be logged for every message using log4j.properties

The pattern can be used to customize the format of the logged message. The supported formats are :

Format Specifier Description
%C The complete class name that has invoked the log
%d The timestamp when log request is invoked. Further customized using java's DateFormat style of abbreviations like %d{yyyy-MM-dd HH:mm:ss,SSS} which incidentally is the default used.
%F The source file name that makes the log request.
%l The source file name, method name and line number where log request is made.
%L The line number of the source file where log request is made.
%m The actual message logged.
%M The method name that makes the log request.
%n New line character
%p The log level used in the log request.
%r The time elapsed between start of the application and the log request in milliseconds.
%t The java thread name that nakes the log request.