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.

Example:
homeOfAllLogs/MachineName/logFiles.....

Thank you
Jim Tyrrell

-----Original Message-----
From: Ray Thomas [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 1:35 PM
To: [EMAIL PROTECTED]
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:
<root>
  <priority value="debug" hostname-affinity="APP_QA_01" />
  <priority value="warn" hostname-affinity="APP_PROD_01" />
  ...
</root>
Or perhaps using regex matching to be more flexible, something like:
<root>
  <priority value="debug" hostname-affinity-match=".*QA.*" />
  <priority value="warn" hostname-affinity-match=".*" />
  ...
</root>

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
  value   CDATA #REQUIRED
  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.

Thanks!

-R



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to