|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.qfs.lib.util.LogSetup
This utility class simplifies the setup of the logging system via command line options. It supports a wide range of options that give access to almost every aspect of the logging system.
Usage:
// create your ArgsParser
as usual.
ArgsParser ap = new ArgsParser (...);
// add the logging options
LogSetup.instance().addOptions(ap);
// parse as usual
int restargs = ap.parse(args);
// then let the LogSetup do its job
LogSetup.instance().setupLogging("myname", ap.getOptions());
...
// to clean up and finish:
LogSetup.instance().stopLogging();
The following options are handled by LogSetup:
Logger levels | |
---|---|
-log-name value |
Set the level of the Logger named
name to value (see Logger.setLogLevel ).
|
Log class settings | |
-logoutputlevel value |
Set the ouput log level to value (see Log.setOutputLevel ).
|
-logprequeuelevel value |
Set the pre queue level to value (see Log.setPreQueueLevel ).
|
-logqueueing [value] |
Turn on queueing (default is true, use value false to turn off,
(see Log.setQueueing ).
|
-logqueuesize value |
Set the size of the log queue to value (see Log.setQueueSize ).
|
-logqueuedrop [value] |
Set whether messages should be dropped when the queue overflows (default is
false, use with great care, see Log.setDropOnOverflow ).
|
-logflushsize value |
Set the size of the flush buffer to value (see Log.setFlushBufferSize ).
|
-logflushlevel value |
Set the flush trigger level to value (see Log.setFlushTriggerLevel ).
|
-logpostflush value |
Set the post flush size to value (see Log.setPostFlushSize ).
|
Writing to a file | |
-logfile name |
Log messages to the file named name. |
-logfilelevel value |
Write only messages with a level up to value to the log file (default is -1, meaning write all messages). |
-logfilesize value |
Limit the size of a log file to value kByte. If set, a
RingFileLogWriter is used to
create the file.
|
-logfilenum value |
Set the number of log files ot keep in the ring (see RingFileLogWriter ). Ignored unless
-logfilesize is also set.
|
-logfilemode value |
Set the creation mode for the log file. May be one of "create" ,
"append" or "unique" (see FileLogWriter , default is
"create" ). Ignored if -logfilesize is also set.
|
-logfileclose [value] |
Set whether the log file should be closed after each write (see FileLogWriter , default is false). Ignored if
-logfilesize is also set.
|
Communication with the log server qflog | |
-logserver [name] |
Contact the logserver named name (default is "qflog" ).
|
-logregistry [value] |
If true, register with the RMI registry so a log server can connect later on (default is false). |
-logport value |
Set the port of the RMI registry to use to value. Ignored unless
-logregistry is also set.
|
-logcreateregistry [value] |
Whether to create an RMI registry if none is available (default is false).
Ignored unless -logregistry is also set.
|
-loglocalonly [value] |
Whether to restrict log server connections to localhost (default is true).
Ignored unless -logregistry is also set.
|
Note: The log server
qflog
contains the class de.qfs.apps.qflog.logview.LogSetup
that
extends this one to recognize the option -logview
which
creates an internal LogView component.
Field Summary | |
static int |
DEFAULT_LOG_FILE_NUM
Default number of files for RingFileLogWriter. |
protected LevelFilter |
fileFilter
The LevelFilter for the file writer. |
protected static LogSetup |
instance
The singleton instance. |
static java.lang.String[] |
OPTIONS
The options the LogSetup passes to the ArgsParser . |
protected LevelFilter |
remoteFilter
The LevelFilter for the remote writer. |
Constructor Summary | |
protected |
LogSetup()
Protected constructor. |
Method Summary | |
void |
addOptions(ArgsParser parser)
Add the LogSetup's options to an ArgsParser, so it will recognize them. |
LevelFilter |
getFileFilter()
Get the LevelFilter returned from FileLogWriter.logToFile or
RingFileLogWriter.logToFile . |
LevelFilter |
getRemoteFilter()
Get the LevelFilter returned from RemoteLogWriter.logRemote . |
static LogSetup |
instance()
Get the singleton LogSetup instance. |
void |
setupLogging(java.lang.String client,
ArgsParser ap)
Set up the logging system after the ArgsParser
did its job. |
void |
stopLogging()
Stop the logging system: call Log.setQueueing(false) to flush pending messages and close open log
files and disconnect from the log server as necessary. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static LogSetup instance
public static final java.lang.String[] OPTIONS
ArgsParser
.public static final int DEFAULT_LOG_FILE_NUM
protected LevelFilter fileFilter
protected LevelFilter remoteFilter
Constructor Detail |
protected LogSetup()
instance
method
instead.Method Detail |
public static LogSetup instance()
public void addOptions(ArgsParser parser)
parser
- The parser to add the options to.public void setupLogging(java.lang.String client, ArgsParser ap)
ArgsParser
did its job.client
- The client name to use for log files and qflog.ap
- The ArgsParser that parsed the command line.public void stopLogging()
Log.setQueueing(false)
to flush pending messages and close open log
files and disconnect from the log server as necessary.public LevelFilter getFileFilter()
FileLogWriter.logToFile
or
RingFileLogWriter.logToFile
.public LevelFilter getRemoteFilter()
RemoteLogWriter.logRemote
.
|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |