org.apache.log.format

Class AvalonFormatter

Implemented Interfaces:
Formatter, Formatter

public class AvalonFormatter
extends ExtendedPatternFormatter

This formatter extends ExtendedPatternFormatter so that CascadingExceptions are formatted with all nested exceptions.
Author:
Avalon Development Team

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.log.format.PatternFormatter

PatternFormatter.PatternRun

Field Summary

static boolean
DEFAULT_PRINT_CASCADING
The constant defining the default behaviour for printing nested exceptions.
static int
DEFAULT_STACK_DEPTH
The constant defining the default stack depth when none other is specified.

Fields inherited from class org.apache.log.format.PatternFormatter

MAX_TYPE

Constructor Summary

AvalonFormatter(String pattern)
Construct the formatter with the specified pattern and which which prints out exceptions to stackDepth of 8.
AvalonFormatter(String pattern, int stackDepth, boolean printCascading)
Construct the formatter with the specified pattern and which which prints out exceptions to stackDepth specified.

Method Summary

protected String
formatPatternRun(LogEvent event, PatternFormatter.PatternRun run)
Formats a single pattern run (can be extended in subclasses).
protected String
getStackTrace(Throwable throwable, String format)
Utility method to format stack trace.
protected int
getTypeIdFor(String type)
Retrieve the type-id for a particular string.

Methods inherited from class org.apache.log.format.ExtendedPatternFormatter

formatPatternRun, getTypeIdFor

Methods inherited from class org.apache.log.format.PatternFormatter

format, formatPatternRun, getCategory, getContext, getContextMap, getContextStack, getMessage, getPriority, getRTime, getStackTrace, getThread, getTime, getTypeIdFor, parse, setFormat

Field Details

DEFAULT_PRINT_CASCADING

public static final boolean DEFAULT_PRINT_CASCADING
The constant defining the default behaviour for printing nested exceptions.
Field Value:
true

DEFAULT_STACK_DEPTH

public static final int DEFAULT_STACK_DEPTH
The constant defining the default stack depth when none other is specified.
Field Value:
8

Constructor Details

AvalonFormatter

public AvalonFormatter(String pattern)
Construct the formatter with the specified pattern and which which prints out exceptions to stackDepth of 8.
Parameters:
pattern - The pattern to use to format the log entries

AvalonFormatter

public AvalonFormatter(String pattern,
                       int stackDepth,
                       boolean printCascading)
Construct the formatter with the specified pattern and which which prints out exceptions to stackDepth specified.
Parameters:
pattern - The pattern to use to format the log entries
stackDepth - The depth to which stacktraces are printed out
printCascading - true enables printing of nested exceptions, false only prints out the outermost exception

Method Details

formatPatternRun

protected String formatPatternRun(LogEvent event,
                                  PatternFormatter.PatternRun run)
Formats a single pattern run (can be extended in subclasses).
Overrides:
formatPatternRun in interface ExtendedPatternFormatter
Parameters:
run - the pattern run to format.
Returns:
the formatted result.

getStackTrace

protected String getStackTrace(Throwable throwable,
                               String format)
Utility method to format stack trace.
Overrides:
getStackTrace in interface PatternFormatter
Parameters:
throwable - the throwable instance
format - ancilliary format parameter - allowed to be null
Returns:
the formatted string

getTypeIdFor

protected int getTypeIdFor(String type)
Retrieve the type-id for a particular string.
Overrides:
getTypeIdFor in interface ExtendedPatternFormatter
Parameters:
type - the string
Returns:
the type-id