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 Michael Heinen <mh...@googlemail.com> on 2018/03/01 10:40:02 UTC

Property Substitution - lookup default value?

I would like to use a system var in the file name. If it is not 
specified an environment var should be used as fallback.

I tried
1) fileName="${sys:valueA:-env:valueB}/foo.log"
2) fileName="${sys:valueA:-${env:valueB}}/foo.log"
3) <Properties>
         <Property name="valueA">${env:valueB}</Property>
     </Properties>
     fileName="${sys:valueA}foo.log"

None of them worked.
Is there any way to achieve this?

Thanks,
Michael



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Property Substitution - lookup default value?

Posted by Remko Popma <re...@gmail.com>.
Looking at the below JIRA tickets, that is supposed to be fixed in 2.8. What Log4j version are you using?

Please see https://issues.apache.org/jira/browse/LOG4J2-1589
https://issues.apache.org/jira/browse/LOG4J2-1243

You can try modifying 

(Shameless plug) Every java main() method deserves http://picocli.info

> On Mar 1, 2018, at 19:40, Michael Heinen <mh...@googlemail.com> wrote:
> 
> I would like to use a system var in the file name. If it is not specified an environment var should be used as fallback.
> 
> I tried
> 1) fileName="${sys:valueA:-env:valueB}/foo.log"
> 2) fileName="${sys:valueA:-${env:valueB}}/foo.log"
> 3) <Properties>
>         <Property name="valueA">${env:valueB}</Property>
>     </Properties>
>     fileName="${sys:valueA}foo.log"
> 
> None of them worked.
> Is there any way to achieve this?
> 
> Thanks,
> Michael
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>