logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Re: Start-up configuration
Date Wed, 22 Oct 2008 13:48:05 GMT

On Wed, 22 Oct 2008 04:43:04 -0700 (PDT)
  Chris Kimball <mail@cvkimball.com> wrote:
> 
> I'm using a DOMConfigurator successfully in a jar-bundled, cross platform
> app.
> 
> But the configuration file is currently a resource within the bundle,
> unmodifiable by a user.
> 
> I'd like to copy the configuration file out once the app gets started and
> the app knows where to place files, so that the user can set his own warning
> levels, etc.
> 
> 1. How do I start the app then have the app take it's configuration file
> from an internally calculated area?
> 

What do you mean by "Internally calculated area".  Internally calculated by 
the application?  Internally calculated by the user?  Other?

Users can specify the config file by setting...

-Dlog4j.configuration=file:/path/to/log4j.xml

There is really no need to manually configure log4j.  And I really discourage 
placing the log4j config file in your application and any manual configuration 
facility should be user-specified, not library specified.  Logging is a 
user-concern, not a library writer concern.  If users want logging, they can 
always place a log4j.properties or log4j.xml file in the classpath and they'll 
get their logging.  You can provide a suggested config file separately, but 
don't load it yourself.  That's the user's domain.

> 2. How do I specify an output file on a cross platform basis?  If I define
> the output log file as "log.txt", what directory does it turn up in under
> various systems?
> 

You can specify a Java system property, such as "log.home" and reference it 
as...

log4j.appender.MYAppender.File=${log.home}/logs/log.txt

The user can set this value by adding -Dlog.home=/path/to/logdir


Jake

> Chris Kimball
> -- 
> View this message in context: 
>http://www.nabble.com/Start-up-configuration-tp20108988p20108988.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Mime
View raw message