Home of: [Atelier "FUJIGURUMA"] >> [PTLog hosted by SourceForge.net]

SEE "For Readers of English Version",
or Japanese version of this page

Bundle taps

This section explains how to bundle LogTaps for configuration convenience.

Please see also classes belonging to basic.bundle package of demonstration implementation.

Overview

Class names

In this tutorial, abbreviated class names are used. Complete names are shown below.

Classes of PTLog

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

Create 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

Plug into logging 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();
}

Create LogDirector

Then, 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);
}

    ....

Create LogTaps

This means that each LogTaps use LogDirector instance LogConfig#DIRECTOR as initial log destination.

Plug into logging framework

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

Plug into logging 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.


To next section "Format values"