This formater formats the LogEvents according to a input pattern string.
The format of each pattern element can be %[+|-][#[.#]]{field:subformat}
.
The +|-
indicates left or right justify.
The #.#
indicates the minimum and maximum size of output. You may omit the values and the field will be formatted without size restriction.
You may specify #
, or #.
to only define the minimum size.
You may specify .#
to only define the maximum size.
field
indicates which field is to be output and must be one of properties of LogEvent. The following fields are currently supported:
category | Category value of the logging event. |
context | Context value of the logging event. |
message | Message value of the logging event. |
time | Time value of the logging event. |
rtime | Relative time value of the logging event. |
throwable | Throwable value of the logging event. |
priority | Priority value of the logging event. |
thread | Name of the thread which logged the event. |
subformat
indicates a particular subformat to use on the specified field, and is currently only supported by:
context | Specifies the context map parameter name. |
time | Specifies the pattern to be pass to {@link java.text.SimpleDateFormat SimpleDateFormat} to format the time. |
A simple example of a typical PatternFormatter format would be:
%{time} %5.5{priority}[%-10.10{category}]: %{message}
This would produce a line like:
1000928827905 DEBUG [ junit]: Sample message
The format string specifies that the logger should first print the time value of the log event without size restriction, then the priority of the log event with a minimum and maximum size of 5, then the category of the log event right justified with a minimum and maximum size of 10, followed by the message of the log event without any size restriction.
@author
Avalon Development Team
@author Peter Donald
@author
Sylvain Wallez
@author
Leif Mortenson
@version CVS $Revision: 1.42 $ $Date: 2004/02/28 11:31:24 $