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
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.
| Modifier and Type | Class and Description |
|---|---|
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private final Date | |
| private PatternFormatter. | |
| private SimpleDateFormat | |
| protected static final int | MAX_TYPE
The maximum value used for TYPEs. |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final int | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public | PatternFormatter(final String
the patter pattern)Creation of a new patter formatter baseed on a supplied pattern. |
| Modifier and Type | Method and Description |
|---|---|
| private int | Returns: the number of characters in pattern runthe stack on which to place patterns stack, final char[] the input string pattern, int the start of pattern run index)Extract and build a pattern from input string. |
| private int | Returns: the number of characters in runthe stack on which to place runs stack, final char[] the input string pattern, int the start of the text run index)Extract and build a text run from input string. |
| private void | append(final StringBuffer
the StringBuffer sb, final int the minimum size of output (0 to ignore) minSize, final int the maximum size of output (0 to ignore) maxSize, final boolean true if the string is to be right justified in it's box. rightJustify, final String the input string output)Utility to append a string to buffer given certain constraints. |
| private void | appendWhiteSpace(final StringBuffer
the StringBuffer sb, int the number of spaces to append length)Append a certain number of whitespace characters to a StringBuffer. |
| public String | Returns: the formatted outputthe event event)Implements org. |
| protected String | Returns: the formatted result.the pattern run to format. runFormats a single pattern run (can be extended in subclasses). |
| protected String | Returns: the formatted stringthe category string category, final String ancilliary format parameter - allowed to be null format)Utility method to format category. |
| protected String | Returns: the formatted stringthe context map map, final String ancilliary format parameter - allowed to be null format)Utility method to format context map. |
| protected String | Returns: the formatted stringthe message string message, final String ancilliary format parameter - allowed to be null format)Utility method to format message. |
| protected String | |
| protected String | |
| protected String | Returns: the formatted stringthe throwable instance throwable, final String ancilliary format parameter - allowed to be null format)Utility method to format stack trace. |
| protected String | |
| protected String | |
| protected int | Returns: the type-idthe string type)Retrieve the type-id for a particular string. |
| protected final void |
| EOL | back to summary |
|---|---|
| private static final String EOL | |
| m_date | back to summary |
|---|---|
| private final Date m_date | |
| m_formatSpecification | back to summary |
|---|---|
| private PatternFormatter. | |
| m_simpleDateFormat | back to summary |
|---|---|
| private SimpleDateFormat m_simpleDateFormat | |
| MAX_TYPE | back to summary |
|---|---|
| protected static final int MAX_TYPE The maximum value used for TYPEs. Subclasses can define their own TYPEs
starting at | |
| SPACE_1 | back to summary |
|---|---|
| private static final String SPACE_1 | |
| SPACE_16 | back to summary |
|---|---|
| private static final String SPACE_16 | |
| SPACE_2 | back to summary |
|---|---|
| private static final String SPACE_2 | |
| SPACE_4 | back to summary |
|---|---|
| private static final String SPACE_4 | |
| SPACE_8 | back to summary |
|---|---|
| private static final String SPACE_8 | |
| TYPE_CATEGORY | back to summary |
|---|---|
| private static final int TYPE_CATEGORY | |
| TYPE_CATEGORY_STR | back to summary |
|---|---|
| private static final String TYPE_CATEGORY_STR | |
| TYPE_CONTEXT | back to summary |
|---|---|
| private static final int TYPE_CONTEXT | |
| TYPE_CONTEXT_STR | back to summary |
|---|---|
| private static final String TYPE_CONTEXT_STR | |
| TYPE_MESSAGE | back to summary |
|---|---|
| private static final int TYPE_MESSAGE | |
| TYPE_MESSAGE_STR | back to summary |
|---|---|
| private static final String TYPE_MESSAGE_STR | |
| TYPE_PRIORITY | back to summary |
|---|---|
| private static final int TYPE_PRIORITY | |
| TYPE_PRIORITY_STR | back to summary |
|---|---|
| private static final String TYPE_PRIORITY_STR | |
| TYPE_RELATIVE_TIME | back to summary |
|---|---|
| private static final int TYPE_RELATIVE_TIME | |
| TYPE_RELATIVE_TIME_STR | back to summary |
|---|---|
| private static final String TYPE_RELATIVE_TIME_STR | |
| TYPE_TEXT | back to summary |
|---|---|
| private static final int TYPE_TEXT | |
| TYPE_THREAD | back to summary |
|---|---|
| private static final int TYPE_THREAD | |
| TYPE_THREAD_STR | back to summary |
|---|---|
| private static final String TYPE_THREAD_STR | |
| TYPE_THROWABLE | back to summary |
|---|---|
| private static final int TYPE_THROWABLE | |
| TYPE_THROWABLE_STR | back to summary |
|---|---|
| private static final String TYPE_THROWABLE_STR | |
| TYPE_TIME | back to summary |
|---|---|
| private static final int TYPE_TIME | |
| TYPE_TIME_STR | back to summary |
|---|---|
| private static final String TYPE_TIME_STR | |
| PatternFormatter | back to summary |
|---|---|
| public PatternFormatter(final String pattern) Creation of a new patter formatter baseed on a supplied pattern.
| |
| addPatternRun | back to summary |
|---|---|
| private int addPatternRun(final Stack<E> stack, final char[] pattern, int index) Extract and build a pattern from input string.
| |
| addTextRun | back to summary |
|---|---|
| private int addTextRun(final Stack<E> stack, final char[] pattern, int index) Extract and build a text run from input string. It does special handling of '\n' and '\t' replaceing them with newline and tab.
| |
| append | back to summary |
|---|---|
| private void append(final StringBuffer sb, final int minSize, final int maxSize, final boolean rightJustify, final String output) Utility to append a string to buffer given certain constraints.
| |
| appendWhiteSpace | back to summary |
|---|---|
| private void appendWhiteSpace(final StringBuffer sb, int length) Append a certain number of whitespace characters to a StringBuffer.
| |
| format | back to summary |
|---|---|
| public String format(final LogEvent event) Implements org. Format the event according to the pattern. | |
| formatPatternRun | back to summary |
|---|---|
| protected String formatPatternRun(final LogEvent event, final PatternFormatter. Formats a single pattern run (can be extended in subclasses).
| |
| getCategory | back to summary |
|---|---|
| protected String getCategory(final String category, final String format) Utility method to format category. | |
| getContextMap | back to summary |
|---|---|
| protected String getContextMap(final ContextMap map, final String format) Utility method to format context map.
| |
| getMessage | back to summary |
|---|---|
| protected String getMessage(final String message, final String format) Utility method to format message. | |
| getPriority | back to summary |
|---|---|
| protected String getPriority(final Priority priority, final String format) Get formatted priority string. | |
| getRTime | back to summary |
|---|---|
| protected String getRTime(final long time, final String format) Utility method to format relative time. | |
| getStackTrace | back to summary |
|---|---|
| protected String getStackTrace(final Throwable throwable, final String format) Utility method to format stack trace. | |
| getThread | back to summary |
|---|---|
| protected String getThread(final String format) Get formatted thread string. | |
| getTime | back to summary |
|---|---|
| protected String getTime(final long time, final String format) Utility method to format time. | |
| getTypeIdFor | back to summary |
|---|---|
| protected int getTypeIdFor(final String type) Retrieve the type-id for a particular string.
| |
| parse | back to summary |
|---|---|
| protected final void parse(final String patternString) Parse the input pattern and build internal data structures.
| |
| Modifier and Type | Field and Description |
|---|---|
| public String | |
| public String | |
| public int | |
| public int | |
| public boolean | |
| public int |
| Access | Constructor and Description |
|---|---|
| protected |
| m_data | back to summary |
|---|---|
| public String m_data | |
| m_format | back to summary |
|---|---|
| public String m_format | |
| m_maxSize | back to summary |
|---|---|
| public int m_maxSize | |
| m_minSize | back to summary |
|---|---|
| public int m_minSize | |
| m_rightJustify | back to summary |
|---|---|
| public boolean m_rightJustify | |
| m_type | back to summary |
|---|---|
| public int m_type | |
| PatternRun | back to summary |
|---|---|
| protected PatternRun() | |