AW: AW: using variables in log4j xml file

2006-08-23 Thread Patrick Wyss
hi,

 So, you've verified that the env. scope works to look up OS 
 properties in Log4j?

i didn't exactly had this verified on the command line at the time of my last 
post ;-)
and: no, it doesn't work :-[
not outside of ant, that is. shame on me.

 If this works, I guess I stand corrected on my 
 previous statement where
 I said that this sort of thing wasn't recognized as anything 
 special by Log4j. 
 Or is it that the System class loads up all existing OS 
 properties using the
 name of the OS property prefixed by env., so that it isn't 
 anything special
 that Log4j is doing, but just a standard Java feature?

unfortunately this is not the case. it's just my ant build script which does 
load the OS-specific environment variables, and prepends them with env.. i 
have no clue how ant is doing this, but probably it could be done your own 
application as well.

bottomline: you have to pass the parameter to java with the -D switch like this
java -Dlog.dir=%LOG_DIR%

regards
patrick




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



Re: AW: using variables in log4j xml file

2006-08-23 Thread James Stauffer

Ant uses a command like the following to do that:
   property environment=env/


On 8/23/06, Patrick Wyss [EMAIL PROTECTED] wrote:

hi,

 So, you've verified that the env. scope works to look up OS
 properties in Log4j?

i didn't exactly had this verified on the command line at the time of my last 
post ;-)
and: no, it doesn't work :-[
not outside of ant, that is. shame on me.

 If this works, I guess I stand corrected on my
 previous statement where
 I said that this sort of thing wasn't recognized as anything
 special by Log4j.
 Or is it that the System class loads up all existing OS
 properties using the
 name of the OS property prefixed by env., so that it isn't
 anything special
 that Log4j is doing, but just a standard Java feature?

unfortunately this is not the case. it's just my ant build script which does load the 
OS-specific environment variables, and prepends them with env.. i have no 
clue how ant is doing this, but probably it could be done your own application as well.

bottomline: you have to pass the parameter to java with the -D switch like this
java -Dlog.dir=%LOG_DIR%

regards
patrick




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





--
James Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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



Re: AW: using variables in log4j xml file

2006-08-22 Thread Jacob Kjome

Hi Patrick,

So, you've verified that the env. scope works to look up OS properties in
Log4j?  If this works, I guess I stand corrected on my previous statement where
I said that this sort of thing wasn't recognized as anything special by Log4j. 
Or is it that the System class loads up all existing OS properties using the
name of the OS property prefixed by env., so that it isn't anything special
that Log4j is doing, but just a standard Java feature?

Farzad, can you post a message back here stating whether the syntax
${env.MY_PROPERTY} works to pick up your OS properties?

Jake

Quoting Patrick Wyss [EMAIL PROTECTED]:

 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:[EMAIL PROTECTED]
  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 [EMAIL PROTECTED]:
 
   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:[EMAIL PROTECTED]
   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 [EMAIL PROTECTED]:
  
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: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
 
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 



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





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