logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Wyss" <Patrick.W...@mobilesolutions.ch>
Subject AW: using variables in log4j xml file
Date Tue, 22 Aug 2006 07:36:47 GMT
farzad,

as jake already pointed out, there are 2 solutions to your problem:
1. specify a system property by -D as described in the mail from 21. August 2006 22:17
or
(and i guess this is what you are looking for)
2. if you want to access the OS environment property then you have to access it with ${env.MY_PROPERTY}

so on windows you would do 
SET MY_PROPERTY=c:\my_log_directory

and in your log4j.xml you would access it:
<param name="File" value="${env.MY_PROPERTY}/server.log"/>

patrick

> -----Urspr√ľngliche Nachricht-----
> Von: Jacob Kjome [mailto:hoju@visi.com]
> Gesendet: Montag, 21. August 2006 22:17
> An: Log4J Users List
> Betreff: RE: using variables in log4j xml file
> 
> 
> 
> Well, System properties are not the same as OS environment 
> properties.  If you
> want an OS environment property to exist in the JVM, you will 
> have to set it
> via the -D parameter on the command line, such as (on windows)....
> 
> java -Dlog.dir=%LOG_DIR% MyClass
> 
> Then, in your log4j.xml file...
> 
> <param name="File"
>  value="${log.dir}/jboss/${jboss.server.name}/server.log"/>
> 
> 
> Jake
> 
> Quoting Farzad Kohantorabi <farzad.kohantorabi@mahjongmania.com>:
> 
> > Jake,
> >
> > Thanks for your sharp response. What I need to do is to set 
> a variable
> > outside the Log4j.xml file and have all the log redirected 
> to the path
> > specified in that variable. By environment variable I meant 
> what you set
> > in you windows property window, like PATH and CLASS_PATH.
> >
> > Well, I have the following in my log4j.xml file:
> >
> > <param name="File"
> > value="${LOG_DIR}/jboss/${jboss.server.name}/server.log"/>
> >
> > And I tried to set the LOG_DIR both in the windows 
> properties window and
> > -D java option but they didn't seem to work. Do you have 
> any idea why?
> >
> > Farzad-
> >
> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: Monday, August 21, 2006 3:41 PM
> > To: Log4J Users List
> > Subject: Re: using variables in log4j xml file
> >
> >
> > When you say "environment variables", do you mean System (JVM-wide)
> > properties?
> > If so, then you just reference them as ${mysyspropname}.  I 
> imagine that
> > JBoss
> > sets some system properties and that is probably what you are seeing
> > referenced
> > in the log4j config files you speak of.  The example you 
> provide where
> > the
> > property name is prefixed with "env" is invalid.  There's 
> no specific
> > "env"
> > scope, or any scope for that matter, used by Log4j to resolve
> > properties.
> >
> > Jake
> >
> > Quoting Farzad Kohantorabi <farzad.kohantorabi@mahjongmania.com>:
> >
> > > Hi group,
> > >
> > >
> > >
> > > I am not sure if it is the right place to ask this 
> question but I have
> > > seen usage of jboss variables in the log4j.xml file. However, I am
> > > wondering if it is possible to use environment variables 
> in the config
> > > file, something like ${env.LOG_DIR}.
> > >
> > >
> > >
> > >
> > >
> > > Thanks,
> > >
> > > Farzad-
> > >
> > >
> >
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> 



---------------------------------------------------------------------
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