com.devexperts.logging
Class LogFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by com.devexperts.logging.LogFormatter

public class LogFormatter
extends Formatter

Formatter for log messages. It is used for formatting both log4j and java.util.logging log messages. Performs conversion of thread names according to patterns specified in configuration file.

If the system property logformatter.properties is specified, then it should contain an URL to the configuration file. Otherwise, configuration is loaded from classpath, using /META-INF/logformatter.properties file.

The format of the file is:

Configuration file is loaded during class loading. Any errors which occur in this class are printed in System.err.

Sample configuration file can be found in etc/logformatter.properties.

This class is not intended to be used standalone. It is a part of implementation of com.devexperts.logging package.

See Also:
DetailedLogLayout

Field Summary
static String CONFIG_FILE_PROPERTY
           
static String DEFAULT_CONFIG_FILE
           
 
Constructor Summary
LogFormatter()
           
LogFormatter(TimeZone zone)
           
 
Method Summary
 String format(char level_char, long time, String thread_name, String logger_name, String msg)
          Formats log message.
 String format(LogRecord record)
          Used by java.util.logging logging.
 
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILE_PROPERTY

public static final String CONFIG_FILE_PROPERTY
See Also:
Constant Field Values

DEFAULT_CONFIG_FILE

public static final String DEFAULT_CONFIG_FILE
See Also:
Constant Field Values
Constructor Detail

LogFormatter

public LogFormatter()

LogFormatter

public LogFormatter(TimeZone zone)
Method Detail

format

public String format(LogRecord record)
Used by java.util.logging logging. Formats messages with the same format as for log4j.

Specified by:
format in class Formatter

format

public String format(char level_char,
                     long time,
                     String thread_name,
                     String logger_name,
                     String msg)
Formats log message.

Returns:
Formatted message.
Throws:
NullPointerException - when thread_name, logger_name, or msg are null.


Copyright © 2013 Devexperts. All Rights Reserved.