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 Contreras García Juan Manuel <PO...@bbva.bancomer.com> on 2004/04/07 23:36:45 UTC

root path definition ...

Hi ... (sorry, but my english is not good ... )

I convert a java program to a NT service, but we have a 
proble with the NT paths (because the default path in a nt service is
winnt -> system32 )

We need know if is possible in dinamic form configure the 
absolute path for the log files in log4j ...

For example, in the jvm with -D option set a base root for the
path and how get that in log4j ...

Thanks to all ...

==== In spanish ===
convertimos un programa de java en un servicio de NT,
ahora necesitamos saber si es posible configurar a log4j
de manera dinamica una ruta para colocar los logs, ya que
tenemos problemas con las rutas relativas, pues estas toman
como ruta base a winnt- > systema32 y eso no lo necesitamos asi.

Hemos usado la opcion de -D en el jvm pero no sabemos si es posible
que log4j la use para salvar los logs del programa o como configurar
a log4j para que use esta variable u otra ...
Gracias ...




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


Re: root path definition ...

Posted by Paul Smith <pa...@lawlex.com.au>.
On Thu, 2004-04-08 at 07:36, Contreras García Juan Manuel wrote:
> Hi ... (sorry, but my english is not good ... )
> 

It's fine, and it's way better than my Spanish!  :)  

> I convert a java program to a NT service, but we have a 
> proble with the NT paths (because the default path in a nt service is
> winnt -> system32 )
> 
> We need know if is possible in dinamic form configure the 
> absolute path for the log files in log4j ...
> 
> For example, in the jvm with -D option set a base root for the
> path and how get that in log4j ...

If you configure log4j using a configuration file (usually
log4j.properties or log4j.xml), the configuration file can use
environment variables (such as via the -D).  So you can create a path
relative to some root.

Let me show you a small sample example from our app's log4j.properties
file:

webappRoot=/var/tomcat4/webapps/

log4j.appender.taipanPropagation=org.apache.log4j.DailyRollingFileAppender
log4j.appender.taipanPropagation.DatePattern='.'yyyy-MM-dd
log4j.appender.taipanPropagation.layout=org.apache.log4j.PatternLayout
log4j.appender.taipanPropagation.layout.conversionPattern=[%d{ISO8601}
%-5p][%20.20c] %m%n
log4j.appender.taipanPropagation.append = true
log4j.appender.taipanPropagation.file=${webappRoot}Taipan/logs/propagation.log



(Note, this is only a small section from our configuration file for this
example).

The above sets a variable "webappRoot" to a physical path, and the
definition of the appender uses that as a base.  You don't have to
define the variable, the last line in the above example could have been:

log4j.appender.taipanPropagation.file=/var/tomcat/webapps/Taipan/logs/propagation.log

For more information, you should take a look at the JavaDocs for the
PropertyConfigurator or the DOMConfigurator:

http://logging.apache.org/log4j/docs/documentation.html

To save yourself some time, I'd recommend picking up a copy of Ceki's
book (see the commercial guide link from the above link). Well worth
having.

cheers,

Paul Smith


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