PatternLayout
found in Log4j. As far as possible all conversions should be available. Q: How do I setup the PatternFormatter in my microlog.properties file? A: You use the microlog.formatter.PatternFormatter.pattern property to set the pattern for the PatternFormatter. Example: # Set the pattern for the PatternFormatter microlog.formatter.PatternFormatter.pattern=%r %c %m %T This would print the relative logging time, the name of the Logger, the logged message and the Throwable object (if not null). The available pattern conversions are: %i : the client id %c : prints the name of the Logger %d : prints the date (absolute time) %m : prints the logged message %P : prints the priority, i.e. Level of the message. %r : prints the relative time of the logging. (The first logging is done at time 0.) %t : prints the thread name. %T : prints the Throwable object. %% : prints the '%' sign.@author Johan Karlsson (johan.karlsson@jayway.se) @since 0.6
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 $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|