The DefinedFormatter
All formatter except this one have a build in layout how the log message is generated. In order to get more flexibility there is a
DefinedFormatter included. The layout of the log message can be defined as parameter.
Syntax
<formatter class="DefinedFormatter">
<parameter name="format" value="defined format"/>
</formatter>
There are a number of tokens that can be used. Every token must be surrounded with
${name}.
Tokens
The following tokens can be used.
${message} This will print the log message itself
${target} The name of the target like INFO, DEBUG or ALL
${class} The full qualified name of the class where the logger was called
${shortclass} Only the class name and not the fqn like above
${date:date format} Will generate the current time. It is possible to define the java timeformat. If not defined and used only as
${date} then the following format is used
yyyy/MM/dd HH:mm:ss.
${ndc} The NDC represented as string
${elapsed} If you have started the TimeTracker then this token will print out the elapsed time. See
SimpleProfiling for more details.
Example
<parameter name="format" value="${date} [${target}] - ${shortclass} : ${message}"/>
This will result in an output like:
2005/07/07 [FATAL] - MyClass : This is my message