From 8a591b1d5e9ef3e4d1f049b4d1ff8fd9a23dfd8a Mon Sep 17 00:00:00 2001 From: sdeangel Date: Fri, 4 Dec 2020 14:36:52 +0100 Subject: [PATCH] Issue 9 Fix Signed-off-by: Stefano De Angelis --- README.md | 2 +- .../java/weblogic/logging/exporter/Startup.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5dc274e..0940e86 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ This section outlines the steps that are required to add the Weblogic Logging Ex It is also strongly recommended that you consider using a different Elastcsearch index name for each domain. If you prefer to place the configuration file in a different location, you can set the environment variable - `WEBLOGIC_LOGGING_EXPORTE_CONFIG_FILE` to point to the location of the file. + `WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE` to point to the location of the file. 1. Restart the servers to activate the changes. After restarting the servers, they will load the WebLogic Logging Exporter and start sending their logs to the specified Elasticsearch instance. You can then diff --git a/src/main/java/weblogic/logging/exporter/Startup.java b/src/main/java/weblogic/logging/exporter/Startup.java index 9d52a1e..4301c09 100644 --- a/src/main/java/weblogic/logging/exporter/Startup.java +++ b/src/main/java/weblogic/logging/exporter/Startup.java @@ -27,8 +27,19 @@ public static void main(String[] argv) { If the file doesn't exist, give WARNING, and use default. It is assumed that when this is integrated to Operator, the system variable will be set. */ + String fileName = - System.getProperty("WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE", DEFAULT_CONFIG_FILE); + System.getProperty( + "WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE", + System.getenv("WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE")); + System.out.println( + "JavaProperty/EnvVariable WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE:" + fileName); + if (fileName == null || fileName.isEmpty()) { + System.out.println( + "Env variable WEBLOGIC_LOGGING_EXPORTER_CONFIG_FILE is not set. Defaulting to:" + + DEFAULT_CONFIG_FILE); + fileName = DEFAULT_CONFIG_FILE; + } File file = new File(fileName); System.out.println("Reading configuration from file name: " + file.getAbsolutePath()); Config config = Config.loadConfig(file);