public class LogConfiguration extends Object
Modifier and Type | Field and Description |
---|---|
static Level |
DEFAULT_ROOT_LOGGER_LEVEL
Constant for the default log level used if level not specified.
|
static String |
DEFAULT_ROOT_LOGGER_NAME
Constant for the default name of the root logger.
|
static String |
TEXT_FORMAT
Constant used to specify the simple text formatting of log output.
|
static String |
XML_FORMAT
Constant used to specify the XML formatting of log output.
|
Constructor and Description |
---|
LogConfiguration()
Simple constructor using the defaults for logger name and level.
|
LogConfiguration(String loggerName,
Level level)
Constructor to create a log config, given a root logger name and level.
|
Modifier and Type | Method and Description |
---|---|
void |
addConsoleHandler(String format)
Set config setting to add a console handler to the root loggger.
|
void |
addFileHandler(String fileName,
int maxFileSize,
int numberFiles,
long rotationMillis,
String format)
Set config setting to add a file handler.
|
void |
addHandler(Handler handler)
Set config setting to add a handler to the root logger.
|
Vector |
getRootHandlers()
Get config setting, the handlers to add to the root logger.
|
Level |
getRootLoggerLevel()
Get config setting, the root logger's log level.
|
String |
getRootLoggerName()
Gets the root logger name.
|
void |
initializeHandlers()
Initialize the handlers.
|
void |
setRootLoggerLevel(Level level)
Set config setting the root logger level.
|
public static final String TEXT_FORMAT
public static final String XML_FORMAT
public static final String DEFAULT_ROOT_LOGGER_NAME
public static final Level DEFAULT_ROOT_LOGGER_LEVEL
public LogConfiguration()
public void initializeHandlers()
public String getRootLoggerName()
public Level getRootLoggerLevel()
public void setRootLoggerLevel(Level level)
level
- the Level to set the root logger's log level to.public void addHandler(Handler handler)
The specified Handler should have its level and formatter set.
handler
- the handler to addpublic void addConsoleHandler(String format)
format
- a String containing the type of output formatting.
This determines the Formatter that the console handler
will have.public void addFileHandler(String fileName, int maxFileSize, int numberFiles, long rotationMillis, String format)
fileName
- the log file name.maxFileSize
- the max size for a file in bytes;
a value of 0 indicates no limit.numberFiles
- the number of log files to rotate through.rotationMillis
- the number of milliseconds
in between a time based log file rotation;
a value of 0 indicates no time based rotation.format
- the format of the output ("text" or "xml").public Vector getRootHandlers()
Copyright © 2023. All rights reserved.