You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Mike Devereaux <Mi...@wnco.com> on 2001/11/13 16:23:39 UTC

Cannot locate "log4j extensions" text?

Hi all,

When I go to the link for Log4J on the jakarta apache website,
I used to be able to navigate via the following links:
   Jakarta
   Log4J
   Documentation
   "extending log4J"

and that would provide me with information on how to extend Log4J's Priorities, Categories, etc.  
Under Documentation, the link to "extending Log4J" no longer appears, and I cant' find it anywhere else on the web site.
Has the ability to extend log4J been lost in the latest release such that the information is no longer valid?

Here is (some of) the text that used to be available under that link:

Introduction
This article assumes familiarity with the log4j User Manual. It builds on fundamental classes described in both the User Manual and the Javadoc API. To assist in illustrating the concepts, a simple case study will be developed along side the explanations. The resulting classes may be used as a template for your own extensions. Condensed (i.e. statements compressed, comments removed) snippets of the case study code are included in this document. 

The Case Study
The case study was developed in a CORBA environment in which the following information for each log entry was needed. The letters in parenthesis represent the corresponding character to be used by the PatternLayout class for formatting. 

Host Name (h) - the IP address or hostname of the physical machine on which the Category was running. 
Server Name (s) - The name of the application server process. In this context, a server refers to a process that accepts requests rather than referring to a machine. The term host refers to a physical machine. Several servers may run on the same host. 
Component Name (b) - Rather than getting bogged down on what constitutes a component, let's assume for the case study that a component is a unit of software worth denoting in the logs. 
Version (v) - the version of the component from which the log entry originated. 
It seems odd to use "b" for the component name. Presently PatternLayout already defines both "C" and "c" for class name and category name respectively. 

A Peek Under the Hood
In principle, if the steps described below are followed closely, there is not a need to understand how the extended classes will be used by log4j. But sometimes software development can be entirely unprincipled. You may wish to extend log4j in a different manner than describe here or you may make a mistake that requires knowledge of what is really going on. (Heaven forbid there be a mistake in this document). In any case, it doesn't hurt to get an idea of what's going on. 

The following describes a "typical" logging scenario in the un-extended log4j case. 
Application code invokes a log request on a Category object. Let's say the info method was invoked. 
The first thing info does is to check if logging has been turned off entirely for the info level. If so, it returns immediately. We'll assume for this scenario that logging has not been turned off for the info level. 
Next info compares the Priority level for this category against Priority.INFO. Assuming the priority warrants logging the message, the category instantiates a LoggingEvent object populated with information available for logging. 

The Category instance passes the LoggingEvent instance to all its Appender implementations. 
Most (but not all) Appender implementations should have an associated subclass of Layout. The Layout subclass is passed the LoggingEvent instance and returns the event's information formatted in a String according to the configuration of the Layout. 
When the Layout subclass is PatternLayout, the format of the event's information is determined by a character sequence similar to the C language library's printf routine. PatternLayout delegates the parsing of this character sequence to a PatternParser instance. 

When the PatternLayout was constructed, it created a PatternParser to tokenize the character sequence. Upon recognizing a token, the 
PatternParser constructs an appropriate PatternConverter subclass, passing it formatting information from the token. Often the PatternConverter subclasses are implemented as static inner classes of PatternParser. The parse method of the PatternParser returns a linked list of these PatternConverter subclasses. 
PatternLayout.format() passes the LoggingEvent to each PatternConverter subclass in the linked list. Each link in the list selects a particular item from the LoggingEvent, converts this item to a String in the proper format and appends it to a StringBuffer. 
The format method returns the resulting String to the Appender for output. 

[remainder deleted for *some* brevity]   :-(

thanks,
~mike


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Cannot locate "log4j extensions" text?

Posted by Paul Glezen <pg...@atdial.net>.
Mike Devereaux wrote:
> 
> Under Documentation, the link to "extending Log4J" no longer appears, and I cant' find it anywhere else on the web site.
> Has the ability to extend log4J been lost in the latest release such that the information is no longer valid?
> 
I wouldn't say it is no longer valid; rather it is deprecated.  I
suspect that's the reason it was removed.  I can send you a copy if
you'd like.  But from your post, you seemed to already have all the
text.

- Paul
-- 
Beware of bugs in the above code.  I have
only proved it correct, not tried it.
-Don Knuth

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>