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 Farzad Kohantorabi <fa...@mahjongmania.com> on 2006/08/21 20:06:33 UTC

using variables in log4j xml file

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-


RE: using variables in log4j xml file

Posted by Jacob Kjome <ho...@visi.com>.
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 <fa...@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 <fa...@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


RE: using variables in log4j xml file

Posted by Farzad Kohantorabi <fa...@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 <fa...@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


Re: using variables in log4j xml file

Posted by Jacob Kjome <ho...@visi.com>.
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 <fa...@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