-
1. Re: How to use environment variables in standalone.xml
ctomc Apr 16, 2012 3:09 PM (in response to foutjo)Hi,
not all elements/configuration flags support expressions.
to make sure if the property you are looking for supports it, you can connect to server with cli
and type ":read-resource-description" on context you are interested (for instance /subsystem=logging/periodic-rotating-file-handler=FILE) where you will get output like this:
"append" => {
"type" => BOOLEAN,
"description" => "Specify whether to append to the target file.",
"expressions-allowed" => false,
"nillable" => true,
"default" => true,
"access-type" => "read-write",
"storage" => "configuration",
"restart-required" => "resource-services"
},
where you can see if attribute supports expression or it doesn't.
As for your exact problem goes, attribute relative-to is it self a system property evaluated, that is why you can just write
<file relative-to="MYENV_VAR" path="Enterprise.log"/>
and it should work.
--
tomaz
-
2. Re: How to use environment variables in standalone.xml
foutjo Apr 17, 2012 7:45 AM (in response to ctomc)Thanks for the help Tomaz,
I tried the following and I still can't get the file to go to the correct location:
<file relative-to="MYENV_VAR" path="/logs/Enterprise.log"/>
<file relative-to="MYENV_VAR" path="\logs\Enterprise.log"/>
<file relative-to="MYENV_VAR" path="Enterprise.log"/>
I want the log file to go to the following folder:
c:\enterprise\logs
SET from command line shows MYENV_VAR pointing to the following:
MYENV_VAR=c:\enterprise
Any ideas?
Thanks.
-
3. Re: How to use environment variables in standalone.xml
ctomc Apr 17, 2012 9:07 AM (in response to foutjo)Hi,
you are right, currently this does not work. Currently only solution for your would be to use
<file path="c:\enterprise\logs\Enterprise.log"/>
it has to be without relative-to attribute.
Best way to address this is to create enhancment in jira, to support expressions for this attributes.
--
tomaz
-
4. Re: How to use environment variables in standalone.xml
foutjo Apr 17, 2012 10:17 AM (in response to ctomc)Bummer.
Thanks for your help.
Not sure how or where to create a jira.
-
5. Re: How to use environment variables in standalone.xml
ctomc Apr 17, 2012 10:20 AM (in response to foutjo)hi,
just go to jira: https://issues.jboss.org/browse/AS7 and in top right corner you have create issue..
--
tomaz
-
6. Re: How to use environment variables in standalone.xml
foutjo Apr 17, 2012 10:21 AM (in response to ctomc)Thanks.
-
7. Re: How to use environment variables in standalone.xml
jamezp Apr 17, 2012 1:58 PM (in response to foutjo)You can add a path though that would work the same. In CLI you could:
/path=my.log.dir:add(path="C:\enterprise")
Then in in the relative-to attribute you just use my.log.dir.
-
8. Re: How to use environment variables in standalone.xml
foutjo Apr 17, 2012 2:38 PM (in response to jamezp)Hi James,
What I am trying to avoid is having to define the log folder location in multiple places.
Our thought was if we define an environment variable then all would just use that variable to define their log file location.
We have multiple systems that log to a specific folder.
The log4j.properties file was able to access the systems environment variables and all worked well.
Seems as though JBoss logging should be able to accomplish the same thing.
I'm not to familiar with the CLI.
How would I add the path definition to the standalone.xml file?
Thanks.
-
9. Re: How to use environment variables in standalone.xml
jamezp Apr 17, 2012 3:15 PM (in response to foutjo)It's not really an issue with JBoss Logging as much as we don't allow it in the logging subsystem in AS 7. I'm probably just missing something, but how many instances of AS7 will be running on a single box?
Anyway, CLI is just a simple command line interface. Once the service is up you could just run:
%JBOSS_HOME%\bin\jboss-cli.bat --connect "/path=my.log.dir:add(path=\"C:\\enterprise\")"
The XML would result in standalone.xml (I'm assuming standalone is being run here):
<paths> <path name="my.log.dir" path="C:\enterprise"/> </paths>
It could easily be scripted as well for each server you deploy. Just a one time run script that goes through and adds the path and the loggers.
-
10. Re: How to use environment variables in standalone.xml
foutjo Apr 17, 2012 3:42 PM (in response to jamezp)Thanks James I appreciate your help.
We currently only have one instance of AS7 running a a single box.
The multiple systems are 3rd party systems that we must work with.
Our system is an AS7 system.
The concept is that we have multiple 3rd party systems that form an enterprise.
All logging for the enterprise must log to the same log folder.
The log folder is defined by an environment variable.
If client decided to change the log folder location only the environment variable has to be
changed for all systems to pick up the change.
Having to document/remember to change multiple locations is something that we try
an avoid.
I hope this explains our enterprise central logging process better.
Hopefully a better way will be developed to accomplish what I am after in the future.
Thanks.