The default text formatting property

File log4j2.xml defines the format to use in formatting logging messages by using the following Property element.

<Property name="file.defaultPattern">%-10.10X{server} %-8.24X{userID} 
      %d{yyyy-MM-dd HH:mm:ss,SSS} %p %notEmpty{&lt;%marker&gt; }%m%n
</Property>

Notice that conversion patterns use control characters, similar to the C language printf function, to specify the output format for the message. For example, %-10.10X{server} has the following meaning:

  • %-10.10 – Pad the text with spaces to the right if the output is shorter than 10 characters. Truncate the output if the output is longer than 10 characters, starting from the left-hand side of the text.
  • %X{server} – Add the server name to the output text, replacing the variable {server} with the name of the actual server.
For more information on conversion patterns, refer to the following Apache documentation:

See also