diff -ur log4cxx-0.9.7-orig/docs/introduction.dox log4cxx-0.9.7/docs/introduction.dox
--- log4cxx-0.9.7-orig/docs/introduction.dox 2004-05-10 14:37:08.000000000 +0200
+++ log4cxx-0.9.7/docs/introduction.dox 2004-08-12 13:42:47.000000000 +0200
@@ -719,18 +719,24 @@
The exact default initialization algorithm is defined as follows:
--# Set the configurationOptionStr string variable to the value of
-the log4j.configuration environment variable. The preferred
+-# Check the following environment variables in order:
+log4j.configuration, log4cxx.configuration,
+LOG4J_CONFIGURATION, LOG4CXX_CONFIGURATION and
+set the configurationOptionStr string variable to
+the first value encountered. The preferred
way to specify the default initialization file is through the
-log4j.configuration environment variable. In case the environment
-variable log4j.configuration is not defined, then set the
-string variable configurationOptionStr to its default value
+environment variables. In case none of the environment
+variables is defined, set the string variable
+configurationOptionStr to its default value
"log4j.properties".
@n @n
-# Attempt to convert the configurationOptionStr variable to a
valid file name.
@n @n
--# If no file could be found, abort default
+-# If no file could be found, set the configurationOptionStr
+variable to it's other default value "log4j.xml" and repeat the previous step.
+@n @n
+-# If still no file could be found, abort default
initialization. Otherwise, configure log4cxx from the file name.
@n @n
The {@link log4cxx::PropertyConfigurator PropertyConfigurator}
diff -ur log4cxx-0.9.7-orig/src/logmanager.cpp log4cxx-0.9.7/src/logmanager.cpp
--- log4cxx-0.9.7-orig/src/logmanager.cpp 2004-05-10 14:37:44.000000000 +0200
+++ log4cxx-0.9.7/src/logmanager.cpp 2004-08-12 13:42:43.000000000 +0200
@@ -27,10 +27,24 @@
#include
#include
-#define DEFAULT_CONFIGURATION_FILE _T("log4j.properties")
-#define DEFAULT_XML_CONFIGURATION_FILE _T("log4j.xml")
-#define DEFAULT_CONFIGURATION_KEY _T("log4j.configuration")
-#define CONFIGURATOR_CLASS_KEY _T("log4j.configuratorClass")
+static const TCHAR* DEFAULT_CONFIGURATION_FILE = _T("log4j.properties");
+static const TCHAR* DEFAULT_XML_CONFIGURATION_FILE = _T("log4j.xml");
+
+// Environment variable keys to check for configuration file
+// Checked in order. The first match is taken.
+static const TCHAR* DEFAULT_CONFIGURATION_KEY[] = {_T("log4j.configuration"),
+ _T("log4cxx.configuration"),
+ _T("LOG4J_CONFIGURATION"),
+ _T("LOG4CXX_CONFIGURATION"),
+ 0};
+
+// Environment variable keys to check for a configurator class
+// Checked in order. The first match is taken.
+static const TCHAR* CONFIGURATOR_CLASS_KEY[] = {_T("log4j.configuratorClass"),
+ _T("log4cxx.configuratorClass"),
+ _T("LOG4J_CONFIGURATOR_CLASS"),
+ _T("LOG4CXX_CONFIGURATOR_CLASS"),
+ 0};
using namespace log4cxx;
using namespace log4cxx::spi;
@@ -70,11 +84,27 @@
new RootCategory(Level::DEBUG)));
// Use automatic configration to configure the default hierarchy
- String configuratorClassName =
- OptionConverter::getSystemProperty(CONFIGURATOR_CLASS_KEY,_T(""));
- String configurationOptionStr =
- OptionConverter::getSystemProperty(DEFAULT_CONFIGURATION_KEY,_T(""));
-
+ // Check all automatic configuration keys in order, use the
+ // first set key.
+
+ String configuratorClassName = _T("");
+ for (int i=0; CONFIGURATOR_CLASS_KEY[i]!=0; i++) {
+ configuratorClassName =
+ OptionConverter::getSystemProperty(CONFIGURATOR_CLASS_KEY[i],_T(""));
+ if (!configuratorClassName.empty()) {
+ break;
+ }
+ }
+
+ String configurationOptionStr = _T("");
+ for (int i=0; DEFAULT_CONFIGURATION_KEY[i]!=0; i++) {
+ configurationOptionStr =
+ OptionConverter::getSystemProperty(DEFAULT_CONFIGURATION_KEY[i],_T(""));
+ if (!configurationOptionStr.empty()) {
+ break;
+ }
+ }
+
struct stat buff;
USES_CONVERSION;