MAP | PTLog Documents > Tutorial > PTLog Basic > Bundle taps | << | >> |
This section explains
how to bundle LogTap
s 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 |
LogDirector
In 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 LogTap
s.
It works as intermediate point between LogTap
s and
underlying framework.
At first,
please create LogDirector
instance
to bundle LogTap
s as shown below.
public class LogConfig { .... final static public LogDirector DIRECTOR = new LogDirector(); }
Then,
please create LogTap
s 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); } ....
This means that
each LogTap
s use
LogDirector
instance LogConfig#DIRECTOR
as initial log destination.
Now,
you can choose underlying logging framework of
all LogTap
s 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 LogDirector
s by another one.
Now, you can configure both each LogTap
s
and all ones bundled by LogDirector
together.
MAP | PTLog Documents > Tutorial > PTLog Basic > Bundle taps | << | >> |