Class UniformLogFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- com.sun.enterprise.server.logging.CommonFormatter
-
- com.sun.enterprise.server.logging.AnsiColorFormatter
-
- com.sun.enterprise.server.logging.UniformLogFormatter
-
- All Implemented Interfaces:
LogEventBroadcaster
public class UniformLogFormatter extends AnsiColorFormatter implements LogEventBroadcaster
UniformLogFormatter conforms to the logging format defined by the Log Working Group in Java Webservices Org. The specified format is "[#|DATETIME|LOG_LEVEL|PRODUCT_ID|LOGGER NAME|OPTIONAL KEY VALUE PAIRS| MESSAGE|#]\n"- Author:
- Hemanth Puttaswamy TODO: 1. Performance improvement. We can Cache the LOG_LEVEL|PRODUCT_ID strings and minimize the concatenations and revisit for more performance improvements 2. Need to use Product Name and Version based on the version string that is part of the product. 3. Stress testing 4. If there is a Map as the last element, need to scan the message to distinguish key values with the message argument.
-
-
Field Summary
Fields Modifier and Type Field Description static char
NV_SEPARATOR
static char
NVPAIR_SEPARATOR
-
Constructor Summary
Constructors Constructor Description UniformLogFormatter()
UniformLogFormatter(FormatterDelegate delegate, String excludeFields)
UniformLogFormatter(String excludeFields)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(LogRecord record)
_REVISIT_: Replace the String Array with an HashMap and do some benchmark to determine whether StringCat is faster or Hashlookup for the template is faster.String
formatMessage(LogRecord record)
protected void
getNameValuePairs(StringBuilder buf, LogRecord record)
Sun One Appserver SE/EE? can override to specify their product specific key value pairs.String
getRecordBeginMarker()
String
getRecordDateFormat()
String
getRecordEndMarker()
String
getRecordFieldSeparator()
void
informLogEventListeners(LogEvent logEvent)
Broadcast the log event to registered listeners.void
setDelegate(FormatterDelegate delegate)
void
setRecordBeginMarker(String recordBeginMarker)
void
setRecordDateFormat(String recordDateFormat)
void
setRecordEndMarker(String recordEndMarker)
void
setRecordFieldSeparator(String recordFieldSeparator)
-
Methods inherited from class com.sun.enterprise.server.logging.AnsiColorFormatter
color, getColor, getLoggerColor, getReset, noAnsi
-
Methods inherited from class com.sun.enterprise.server.logging.CommonFormatter
getProductId, isFieldExcluded
-
-
-
-
Field Detail
-
NVPAIR_SEPARATOR
public static final char NVPAIR_SEPARATOR
- See Also:
- Constant Field Values
-
NV_SEPARATOR
public static final char NV_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UniformLogFormatter
public UniformLogFormatter()
-
UniformLogFormatter
public UniformLogFormatter(String excludeFields)
-
UniformLogFormatter
public UniformLogFormatter(FormatterDelegate delegate, String excludeFields)
-
-
Method Detail
-
setDelegate
public void setDelegate(FormatterDelegate delegate)
-
format
public String format(LogRecord record)
_REVISIT_: Replace the String Array with an HashMap and do some benchmark to determine whether StringCat is faster or Hashlookup for the template is faster.
-
formatMessage
public String formatMessage(LogRecord record)
- Overrides:
formatMessage
in classFormatter
-
getNameValuePairs
protected void getNameValuePairs(StringBuilder buf, LogRecord record)
Sun One Appserver SE/EE? can override to specify their product specific key value pairs.
-
getRecordBeginMarker
public String getRecordBeginMarker()
-
setRecordBeginMarker
public void setRecordBeginMarker(String recordBeginMarker)
-
getRecordEndMarker
public String getRecordEndMarker()
-
setRecordEndMarker
public void setRecordEndMarker(String recordEndMarker)
-
getRecordFieldSeparator
public String getRecordFieldSeparator()
-
setRecordFieldSeparator
public void setRecordFieldSeparator(String recordFieldSeparator)
-
getRecordDateFormat
public String getRecordDateFormat()
-
setRecordDateFormat
public void setRecordDateFormat(String recordDateFormat)
-
informLogEventListeners
public void informLogEventListeners(LogEvent logEvent)
Description copied from interface:LogEventBroadcaster
Broadcast the log event to registered listeners.- Specified by:
informLogEventListeners
in interfaceLogEventBroadcaster
-
-