3

I have different logs locations in development and in production, they also may be different platforms, so I want to configure the logs just one time using a environment variable.

Possible locations: C:/logs/ T:/logs/ /var/logs/

In this question they need just that, but it is applied to Java and is using the Java system properties, obviously not available in C++.

So, is there a way to use a environment variable in the log4cxx config file?

Community
  • 1
  • 1
Javier Mr
  • 2,130
  • 4
  • 31
  • 39

1 Answers1

3

It works just the same way as in Java.

For example, in an XML configuration read with log4cxx::xml::DOMConfigurator::configure, containing <param name="file" value="${LOG_DIR}/traces.log"/>, the environment variable LOG_DIR will be correctly substituted. Tested on Linux/Ubuntu 12.01 with log4cxx 0.9.7.

Also see my question and the answer here: https://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/201403.mbox/%3C1378908733.20140324173531%40am-soft.de%3E

Scrontch
  • 3,275
  • 5
  • 30
  • 45
  • 1
    Thx. Actually I did try using ${env:LOG_DIR} as described in the Java version with no luck. Just not prefixing 'env:' works. This solution works, tested on a Windows with a properties file configuration. – Javier Mr Mar 26 '14 at 09:06