Architecting, installing and maintaining your SAS environment

Using environment variables in log4sas

Accepted Solution Solved
Reply
Valued Guide
Posts: 531
Accepted Solution

Using environment variables in log4sas

Hi,

 

I was wondering how to use environment variable values in log4sas. Our use case: place the workspace server logs for different user groups. A user is member of just one, indicated by environment variable TENANT. If I look at the comparable log4j facility there is a possibility to refer to this by ${env.TENANT}. I was hoping for something similar in log4sas like

 

%S{env.TENANT}

But unfortunately it is not provided.

 

Am I overlooking something? Is there another way to accomplish the same (short of specifying a separate logconfig.xml for each user group)? Would, if needed, a feature request garner your support?

 

Kind regards,

- Jan.


Accepted Solutions
Solution
‎03-07-2018 09:13 AM
PROC Star
Posts: 464

Re: Using environment variables in log4sas

Posted in reply to jklaverstijn

Hi Jan,

 

I see that documentation for SAS ESP 4.3/5.1 and SAS DataFlux Data Management Server 2.6 have examples of the form %S{OSENV.env_var_name} in their logging XML - e.g. https://support.sas.com/kb/60/591.html

 

There's another example of it at https://communities.sas.com/t5/SAS-Communities-Library/The-Node-Less-Traveled-Improving-Job-Performa...

 

 

I note that OSENV isn't documented as a key for the S Conversion Character in the SAS 9.4 Logging: Configuration and Programming Reference but it'd be worth a try - you never know Smiley Happy

 

 

Cheers

Paul

View solution in original post


All Replies
Super User
Posts: 9,883

Re: Using environment variables in log4sas

Posted in reply to jklaverstijn

Doesn't

%sysget(TENANT)

do it?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Valued Guide
Posts: 531

Re: Using environment variables in log4sas

Posted in reply to KurtBremser

Unfortunately not in the logconfig.xml, Kurt. This is not SAS code but XML configuration. Sorry for not being more clearly about this.

 

Super User
Posts: 9,883

Re: Using environment variables in log4sas

Posted in reply to jklaverstijn

Ah. The first thing google gave me was the %log4sas autocall macro, so I was thinking SAS code.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎03-07-2018 09:13 AM
PROC Star
Posts: 464

Re: Using environment variables in log4sas

Posted in reply to jklaverstijn

Hi Jan,

 

I see that documentation for SAS ESP 4.3/5.1 and SAS DataFlux Data Management Server 2.6 have examples of the form %S{OSENV.env_var_name} in their logging XML - e.g. https://support.sas.com/kb/60/591.html

 

There's another example of it at https://communities.sas.com/t5/SAS-Communities-Library/The-Node-Less-Traveled-Improving-Job-Performa...

 

 

I note that OSENV isn't documented as a key for the S Conversion Character in the SAS 9.4 Logging: Configuration and Programming Reference but it'd be worth a try - you never know Smiley Happy

 

 

Cheers

Paul

PROC Star
Posts: 464

Re: Using environment variables in log4sas

[ Edited ]
Posted in reply to PaulHomes

I was curious so I tried it out with the RollingFileAppender FileNamePattern value in a SAS 9.4 M5 Workspace Server logconfig.xml and it seems to work (even though it is not documented). Probably best to ask SAS tech support if it is supported and what SAS versions it works with.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 163 views
  • 6 likes
  • 3 in conversation