logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 46941] New: Sub Level Logging Technique
Date Tue, 31 Mar 2009 09:49:25 GMT

           Summary: Sub Level Logging Technique
           Product: Log4j
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: roger77_lb@hotmail.com

While improving code for a logger at hand I found it useful to define my own
levels to be suited to every application I have. That is, different logging
levels defined for different applications.

Moreover, I needed to be able to log a certain type of events no matter what
the chosen level was (see logger.transparentLevels below).

At the beginning, I created a new config parameter as:


which means that err (error) > inf (information) > deb (debug)

which is practically the same story as Apache Log4J' Basic Selection Rule.

To be able to log CDR (Call Detail Records) type events, I have created a new
config parameter as: 


(we can add / modify / displace levels in both parameters according to our

The name 'transparent' was chosen to indicate that the levels listed in
logger.transparentLevels are transparent to the Selection Rule ! A request with
a level listed here passes the Selection Rule no matter what other application
logging settings are.

Till now, we have defined a Reference list and a Transparent List of levels, we
just need one thing, a chosen log level which will define the current logging
settings of our application:


For the currently defined reference logging levels, values could be as listed

err (same as err.0)
inf (same as inf.0)
deb (same as deb.0)
err.2 (any number)
inf.3 (any number)
deb.8 (any number)

I will explain what is the .5 for (in the logger.chosenLogLevel config) below:

The next interesting feature I've added is to be able to use Sub Levels into
each level in an arbitrary fashion using a simple approach: the numbering
system !

logger.chosenLogLevel=deb.4 means:
log all log requests (Logger.Log("deb.4", "This is your log request");) till
level deb and sub level 4
     1. a request with deb.10 will be ignored.
     2. a request with deb.3 / deb.2 / deb.1 / deb / inf / inf.2 / inf.10000,
etc. / err.4, etc. / err will certainly be served.

Note that the technique illustrated here can be used in a way to enable
debugging for an application deployed on a live server, and be able to do
further debugging (for instance, by specifying logger.chosenLogLevel=deb.7)
when a problem is to be debugged. Of course, software developers are required
to include adequate logging requests wherever useful it might be.

Of course, software developers are invited to plan their logging software
architecture so that they define which 'things' are to be considered at which
'level', 'sub level'; and code their sub levels in the most appropriate way,
such as to use 'sub level' numbers in a meaningful way. 

For this purpose, I propose to use SubLevel classes where useful sub levels are
defined as:

public static int sub_level_live = 0;

public static int sub_level_deb = 0;

public static int sub_level_deb_transactions_summary = 1;

public static int sub_level_deb_transactions_full = 2;

public static int sub_level_deb_show_low_level_handshaking = 3;

Those sub levels definitions should be suitable for your application logic.

Can this be implemented in Log4J ? If it already can be done, how is that ? Can
you provide a clear example please ?

If not, what about adding it to Log4J's TODO list ?

Best Regards,
Roger Tannous

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message