| MAP | PTLog Documents > Tutorial > PTLog Basic > Bundle taps | << | >> |
This section explains
how to bundle LogTaps for configuration convenience.
Please see also classes belonging to basic.bundle package of demonstration implementation.
In this tutorial, abbreviated class names are used. Complete names are shown below.
| Notation | Full name |
|---|---|
| JCLProvider | jp.ne.dti.lares.foozy.ptlog.jcl.JCLProvider |
| Log4jProvider | jp.ne.dti.lares.foozy.ptlog.log4j.Log4jProvider |
| LogDirector | jp.ne.dti.lares.foozy.ptlog.LogDirector |
| LogTap | jp.ne.dti.lares.foozy.ptlog.LogTap |
LogDirectorIn the former section, underlying logging framework configuration is written as shown below.
Client.TAP.setServer(Log4jProvider.INSTANCE);
// uses Apache Log4j as underlying framework
Please imagine how complicated underlying framework choice is
when there are many classes having LogTap.
You want to configure them all at once, do not you ?
PTLog provides LogDirector
to bundle your LogTaps.
It works as intermediate point between LogTaps and
underlying framework.
At first,
please create LogDirector instance
to bundle LogTaps as shown below.
public class LogConfig { .... final static public LogDirector DIRECTOR = new LogDirector(); }
LogDirectorThen,
please create LogTaps as shown below
in logging client classes.
public class Client1
{
....
final static
public LogTap TAP =
new LogTap(Client1.class, LogConfig.DIRECTOR);
}
public class Client2
{
....
final static
public LogTap TAP =
new LogTap(Client2.class, LogConfig.DIRECTOR);
}
....
LogTapsThis means that
each LogTaps use
LogDirector instance LogConfig#DIRECTOR
as initial log destination.
Now,
you can choose underlying logging framework of
all LogTaps at once
by invocation of #setServer() on
LogConfig#DIRECTOR.
LogConfig.DIRECTOR.setServer(JCLProvider.INSTANCE);
// uses Jakarata Commons Logging as framework
LogDirector also
uses another LogDirector as initial log destination,
so you can bundle some LogDirectors by another one.
Now, you can configure both each LogTaps
and all ones bundled by LogDirector together.
| MAP | PTLog Documents > Tutorial > PTLog Basic > Bundle taps | << | >> |