use of org.apache.logging.log4j.util.PropertiesUtil in project logging-log4j2 by pwntester.
the class CopyOnWriteSortedArrayThreadContextMap method init.
/**
* Initializes static variables based on system properties. Normally called when this class is initialized by the VM
* and when Log4j is reconfigured.
*/
static void init() {
final PropertiesUtil properties = PropertiesUtil.getProperties();
initialCapacity = properties.getIntegerProperty(PROPERTY_NAME_INITIAL_CAPACITY, DEFAULT_INITIAL_CAPACITY);
inheritableMap = properties.getBooleanProperty(INHERITABLE_MAP);
}
use of org.apache.logging.log4j.util.PropertiesUtil in project logging-log4j2 by pwntester.
the class GarbageFreeSortedArrayThreadContextMap method init.
/**
* Initializes static variables based on system properties. Normally called when this class is initialized by the VM
* and when Log4j is reconfigured.
*/
static void init() {
final PropertiesUtil properties = PropertiesUtil.getProperties();
initialCapacity = properties.getIntegerProperty(PROPERTY_NAME_INITIAL_CAPACITY, DEFAULT_INITIAL_CAPACITY);
inheritableMap = properties.getBooleanProperty(INHERITABLE_MAP);
}
use of org.apache.logging.log4j.util.PropertiesUtil in project logging-log4j2 by pwntester.
the class ThreadContext method init.
/**
* <em>Consider private, used for testing.</em>
*/
static void init() {
ThreadContextMapFactory.init();
contextMap = null;
final PropertiesUtil managerProps = PropertiesUtil.getProperties();
boolean disableAll = managerProps.getBooleanProperty(DISABLE_ALL);
useStack = !(managerProps.getBooleanProperty(DISABLE_STACK) || disableAll);
boolean useMap = !(managerProps.getBooleanProperty(DISABLE_MAP) || disableAll);
contextStack = new DefaultThreadContextStack(useStack);
if (!useMap) {
contextMap = new NoOpThreadContextMap();
} else {
contextMap = ThreadContextMapFactory.createThreadContextMap();
}
if (contextMap instanceof ReadOnlyThreadContextMap) {
readOnlyContextMap = (ReadOnlyThreadContextMap) contextMap;
} else {
readOnlyContextMap = null;
}
}
use of org.apache.logging.log4j.util.PropertiesUtil in project logging-log4j2 by pwntester.
the class AsyncQueueFullPolicyFactory method createDiscardingAsyncQueueFullPolicy.
private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy() {
final PropertiesUtil util = PropertiesUtil.getProperties();
final String level = util.getStringProperty(PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL, Level.INFO.name());
final Level thresholdLevel = Level.toLevel(level, Level.INFO);
LOGGER.debug("Creating custom DiscardingAsyncQueueFullPolicy(discardThreshold:{})", thresholdLevel);
return new DiscardingAsyncQueueFullPolicy(thresholdLevel);
}
use of org.apache.logging.log4j.util.PropertiesUtil in project logging-log4j2 by pwntester.
the class ConsoleAppender method getOutputStream.
private static OutputStream getOutputStream(final boolean follow, final boolean direct, final Target target) {
final String enc = Charset.defaultCharset().name();
OutputStream outputStream;
try {
// @formatter:off
outputStream = target == Target.SYSTEM_OUT ? direct ? new FileOutputStream(FileDescriptor.out) : (follow ? new PrintStream(new SystemOutStream(), true, enc) : System.out) : direct ? new FileOutputStream(FileDescriptor.err) : (follow ? new PrintStream(new SystemErrStream(), true, enc) : System.err);
// @formatter:on
outputStream = new CloseShieldOutputStream(outputStream);
} catch (final UnsupportedEncodingException ex) {
// should never happen
throw new IllegalStateException("Unsupported default encoding " + enc, ex);
}
final PropertiesUtil propsUtil = PropertiesUtil.getProperties();
if (!propsUtil.isOsWindows() || propsUtil.getBooleanProperty("log4j.skipJansi", true) || direct) {
return outputStream;
}
try {
// We type the parameter as a wildcard to avoid a hard reference to Jansi.
final Class<?> clazz = Loader.loadClass(JANSI_CLASS);
final Constructor<?> constructor = clazz.getConstructor(OutputStream.class);
return new CloseShieldOutputStream((OutputStream) constructor.newInstance(outputStream));
} catch (final ClassNotFoundException cnfe) {
LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS);
} catch (final NoSuchMethodException nsme) {
LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS);
} catch (final Exception ex) {
LOGGER.warn("Unable to instantiate {} due to {}", JANSI_CLASS, clean(Throwables.getRootCause(ex).toString()).trim());
}
return outputStream;
}
Aggregations