com.devexperts.logging
Class LogFormatter
java.lang.Object
java.util.logging.Formatter
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:
- pattern=replacement
- "Pattern" uses regular expression syntax.
You can escape "=" in pattern with "\=" syntax.
- "Replacement" string can refer to capturing groups defined in pattern using usual
regular expression syntax "$n", where "n" stands for the number of the group.
- ISO 8859-1 encoding is used.
- Empty lines and lines starting with # or ! are ignored.
Lines containing wrong patterns are ignored.
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
LogFormatter
public LogFormatter()
LogFormatter
public LogFormatter(TimeZone zone)
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.