[jboss-svn-commits] JBoss Common SVN: r3292 - jboss-logmanager/trunk/src/main/java/org/jboss/logmanager.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jun 18 09:51:09 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-18 09:51:07 -0400 (Thu, 18 Jun 2009)
New Revision: 3292
Added:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/DefaultConfigurationLocator.java
Removed:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ClassPathConfigurationLocator.java
Modified:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogManager.java
Log:
Allow configuration file to be specified by a system property
Deleted: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ClassPathConfigurationLocator.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ClassPathConfigurationLocator.java 2009-06-17 19:04:23 UTC (rev 3291)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ClassPathConfigurationLocator.java 2009-06-18 13:51:07 UTC (rev 3292)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.logmanager;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * A configuration locator which looks for a {@code logging.properties} file in the class path.
- */
-public final class ClassPathConfigurationLocator implements ConfigurationLocator {
-
- /** {@inheritDoc} */
- public InputStream findConfiguration() throws IOException {
- final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- if (tccl != null) try {
- return tccl.getResourceAsStream("logging.properties");
- } catch (Exception e) {
- }
- return getClass().getResourceAsStream("logging.properties");
- }
-}
Copied: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/DefaultConfigurationLocator.java (from rev 3268, jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ClassPathConfigurationLocator.java)
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/DefaultConfigurationLocator.java (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/DefaultConfigurationLocator.java 2009-06-18 13:51:07 UTC (rev 3292)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logmanager;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * A configuration locator which looks for a {@code logging.properties} file in the class path, allowing the location
+ * to be overridden via a URL specified in the {@code logging.configuration} system property.
+ */
+public final class DefaultConfigurationLocator implements ConfigurationLocator {
+
+ /** {@inheritDoc} */
+ public InputStream findConfiguration() throws IOException {
+ final String propLoc = System.getProperty("logging.configuration");
+ if (propLoc != null) try {
+ return new URL(propLoc).openStream();
+ } catch (IOException e) {
+ System.err.printf("Unable to read the logging configuration from '%s' (%s)\n", propLoc, e);
+ }
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (tccl != null) try {
+ return tccl.getResourceAsStream("logging.properties");
+ } catch (Exception e) {
+ }
+ return getClass().getResourceAsStream("logging.properties");
+ }
+}
Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogManager.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogManager.java 2009-06-17 19:04:23 UTC (rev 3291)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogManager.java 2009-06-18 13:51:07 UTC (rev 3292)
@@ -207,7 +207,7 @@
if (configured.getAndSet(true)) {
return;
}
- final String confLocClassName = System.getProperty("org.jboss.logmanager.configurationLocator", "org.jboss.logmanager.ClassPathConfigurationLocator");
+ final String confLocClassName = System.getProperty("org.jboss.logmanager.configurationLocator", DefaultConfigurationLocator.class.getName());
final ConfigurationLocator locator = construct(ConfigurationLocator.class, confLocClassName);
final InputStream configuration = locator.findConfiguration();
if (configuration != null) {
@@ -223,7 +223,7 @@
*/
public void readConfiguration(InputStream inputStream) throws IOException, SecurityException {
checkAccess();
- final String confClassName = System.getProperty("org.jboss.logmanager.configurator", "org.jboss.logmanager.PropertyConfigurator");
+ final String confClassName = System.getProperty("org.jboss.logmanager.configurator", PropertyConfigurator.class.getName());
final Configurator configurator = construct(Configurator.class, confClassName);
try {
configurator.configure(inputStream);
More information about the jboss-svn-commits
mailing list