allow overriding from system properties
This commit is contained in:
parent
d05f00d7cb
commit
8aff72c4ee
2 changed files with 10 additions and 4 deletions
|
@ -30,8 +30,10 @@ public class PropertyContextConfiguration extends ContextConfiguration {
|
|||
private static final String[] EMPTY_STRINGS = new String[0];
|
||||
private final Properties properties;
|
||||
|
||||
private PropertyContextConfiguration(final LogContext logContext, final Properties properties) {
|
||||
private PropertyContextConfiguration(final LogContext logContext,
|
||||
final Properties properties) {
|
||||
super(logContext);
|
||||
properties.putAll(System.getProperties());
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
@ -42,7 +44,8 @@ public class PropertyContextConfiguration extends ContextConfiguration {
|
|||
* @param properties the properties used to configure the log context
|
||||
* @return the context configuration for the properties
|
||||
*/
|
||||
public static PropertyContextConfiguration configure(final LogContext logContext, final Properties properties) {
|
||||
public static PropertyContextConfiguration configure(final LogContext logContext,
|
||||
final Properties properties) {
|
||||
final PropertyContextConfiguration config = new PropertyContextConfiguration(
|
||||
Objects.requireNonNull(logContext),
|
||||
Objects.requireNonNull(properties));
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.io.InputStreamReader;
|
|||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import org.xbib.logging.Level;
|
||||
import org.xbib.logging.LogContext;
|
||||
|
@ -75,12 +78,12 @@ public class PropertyLogContextConfigurator implements LogContextConfigurator {
|
|||
}
|
||||
|
||||
private static InputStream findConfiguration() {
|
||||
final String propLoc = System.getProperty("org.xbib.logging.configuration");
|
||||
final String propLoc = System.getProperty("logging.configuration");
|
||||
if (propLoc != null) {
|
||||
try {
|
||||
return URI.create(propLoc).toURL().openStream();
|
||||
} catch (IOException e) {
|
||||
StandardOutputStreams.printError("Unable to read the logging configuration from '%s' (%s)%n", propLoc, e);
|
||||
StandardOutputStreams.printError("Unable to read logging.configuration from '%s' (%s)%n", propLoc, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue