How to give environmental variable path for file appender in configuration file in log4cxx

StackOverflow https://stackoverflow.com/questions/21303415

  •  01-10-2022
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top