logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Tyrrell <JTyrr...@appriss.com>
Subject RE: Hostname Affinity for Logger Config
Date Mon, 01 Apr 2002 18:38:25 GMT
I to am looking for something like this.  I would want it to discover at
runtime the server it is running on and just magically dump the output from
that server into one log directory that is the home for all logs.


Thank you
Jim Tyrrell

-----Original Message-----
From: Ray Thomas [mailto:rthomas-contrib@liveintellect.org]
Sent: Monday, April 01, 2002 1:35 PM
To: log4j-user@jakarta.apache.org
Subject: Hostname Affinity for Logger Config

If this is not the appropriate forum to which feature requests should be
submitted, I apologize.  Someone please let me know if this should be
submitted in a different forum.

Using log4j is certainly more convenient than System.out or System.err
but I haven't found a way to configure it once for my whole environment
and leave it alone.  i.e. Each server to which I deploy a .war file
using log4j must be reconfigured after deployment to the appropriate
settings for the target machine.  If the configuration (xml or
properties file) had a "hostname-affinity" attribute assigned to various
configuration directives, the "root" or other Logger could be configured
based on matching a pattern or literal value with the result of
InetAddress.getLocalHost().getHostName().  That way, the loggers could
be configured such that the same code running on different servers,
would log differently without maintaining multiple configuration files.
This concept would be similar to the "VirtualHost" directive in the
apache webserver config.

For example, (using the xml style config directives) suppose an app is
tested and debugged on a server with hostname=APP_QA_01 and runs in
production on one called APP_PROD_01.   The servers could be configured
concurrently in the same config file using:
  <priority value="debug" hostname-affinity="APP_QA_01" />
  <priority value="warn" hostname-affinity="APP_PROD_01" />
Or perhaps using regex matching to be more flexible, something like:
  <priority value="debug" hostname-affinity-match=".*QA.*" />
  <priority value="warn" hostname-affinity-match=".*" />

The hostname-affinity and hostname-affinity-match attributes could be
added as optional, and be assigned the appropriate defaults so that if
they are omitted, the old behavior of matching any hostname would
continue to work as is.  This could also be applied to other per-server
configuration attributes but the selection of logging priority seems the
most useful to me.

I think the dtd mods would look something like this:
<!-- The priority class is org.apache.log4j.Priority by default -->
<!ELEMENT priority (param*)>
<!ATTLIST priority
  class   CDATA #IMPLIED
  hostname-affinity CDATA "*"
  hostname-affinity-match CDATA ".*"

(Note: The hostname-affinity and hostname-affinity-match could also be
restricted to "either or none, not both," but I wasn't sure how to do
that in a DTD).

Hope this merits putting on the "todo" list.



To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message