Remove dependency on Logger in PropertiesUtil. PropertiesUtil is too low-level at this point to be allowed to use a real StatusLogger.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/03b2da96 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/03b2da96 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/03b2da96 Branch: refs/heads/LOG4J2-1278-gc-free-logger Commit: 03b2da963106a836dff570d4caf81e4cec1f3b38 Parents: 4aa7df8 Author: Matt Sicker <[email protected]> Authored: Sun Feb 21 21:25:41 2016 -0600 Committer: Matt Sicker <[email protected]> Committed: Sun Feb 21 21:25:41 2016 -0600 ---------------------------------------------------------------------- .../apache/logging/log4j/util/PropertiesUtil.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/03b2da96/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java ---------------------------------------------------------------------- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java index bd138e4..4fb3f86 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java @@ -23,9 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.status.StatusLogger; - /** * <em>Consider this class private.</em> * <p> @@ -37,8 +34,6 @@ public final class PropertiesUtil { private static final PropertiesUtil LOG4J_PROPERTIES = new PropertiesUtil("log4j2.component.properties"); - private static final Logger LOGGER = StatusLogger.getLogger(); - private final Properties props; /** @@ -62,7 +57,7 @@ public final class PropertiesUtil { try (final InputStream in = url.openStream()) { properties.load(in); } catch (final IOException ioe) { - LOGGER.error("Unable to read {}", url.toString(), ioe); + logException("Unable to read " + url.toString(), ioe); } } this.props = properties; @@ -81,12 +76,12 @@ public final class PropertiesUtil { try { props.load(in); } catch (final IOException e) { - LOGGER.error("Unable to read {}", source, e); + logException("Unable to read " + source, e); } finally { try { in.close(); } catch (final IOException e) { - LOGGER.error("Unable to close {}", source, e); + logException("Unable to close " + source, e); } } } @@ -221,7 +216,7 @@ public final class PropertiesUtil { try { return new Properties(System.getProperties()); } catch (final SecurityException ex) { - LOGGER.error("Unable to access system properties.", ex); + logException("Unable to access system properties.", ex); // Sandboxed - can't read System Properties return new Properties(); } @@ -266,4 +261,9 @@ public final class PropertiesUtil { public boolean isOsWindows() { return getStringProperty("os.name").startsWith("Windows"); } + + private static void logException(final String message, final Throwable exception) { + System.err.println(message); + exception.printStackTrace(System.err); + } }
