Class BasicLogFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- BasicLogFormatter
-
public class BasicLogFormatter extends java.util.logging.FormatterProvides basic formatting for log messages.This class extends the
java.util.logging.Formatterclass, allowing it to be specified as a formatter for thejava.util.loggingsystem.The static
format(String level, String message, String loggerName)method provides a means of using the same formatting outside of thejava.util.loggingframework. See the documentation of this method for more details.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanOutputLevelDetermines whether the logging level is included in the output.static booleanOutputNameDetermines whether the logger name is included in the output.
-
Constructor Summary
Constructors Constructor Description BasicLogFormatter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringformat(java.lang.String level, java.lang.String message, java.lang.String loggerName)Returns a formatted string representing the specified log entry information.java.lang.Stringformat(java.util.logging.LogRecord logRecord)Returns a formatted string representing the log entry information contained in the specifiedjava.util.logging.LogRecord.
-
-
-
Field Detail
-
OutputLevel
public static boolean OutputLevel
Determines whether the logging level is included in the output.The default value is
true.As this is a static property, changing the value will affect all
BasicLogFormatterinstances, as well as the behaviour of the staticformat(String level, String message, String loggerName)method.
-
OutputName
public static boolean OutputName
Determines whether the logger name is included in the output.The default value is
false.The logger name used for all automatically created
Loggerinstances is "net.htmlparser.jericho".As this is a static property, changing the value will affect all
BasicLogFormatterinstances, as well as the behaviour of the staticformat(String level, String message, String loggerName)method.
-
-
Method Detail
-
format
public java.lang.String format(java.util.logging.LogRecord logRecord)
Returns a formatted string representing the log entry information contained in the specifiedjava.util.logging.LogRecord.This method is not called directly, but is used by the
java.util.loggingframework when this class is specified as a formatter in thelogging.propertiesfile.See the documentation of the parent
java.util.logging.Formatterclass in the Java SDK for more details.- Specified by:
formatin classjava.util.logging.Formatter- Parameters:
logRecord- ajava.util.logging.LogRecordobject containing all of the log entry information.- Returns:
- a formatted string representing the log entry information contained in the specified
java.util.logging.LogRecord.
-
format
public static java.lang.String format(java.lang.String level, java.lang.String message, java.lang.String loggerName)Returns a formatted string representing the specified log entry information.This method is used by the default implementation of the
WriterLogger.log(String level, String message)method.The static properties
OutputLevelandOutputNameaffect what information is included in the output.The static
Config.NewLineproperty determines the character sequence used for line breaks.A line of output typically looks like this:
or if theINFO: this is the log messageOutputNameproperty is set totrue, the output would look similar to this:INFO: [net.htmlparser.jericho] this is the log message- Parameters:
level- a string representing the logging level of the log entry.message- the log message.loggerName- the name of the logger.- Returns:
- a formatted string representing the specified log entry information.
-
-