本文整理汇总了Java中ch.qos.logback.core.util.OptionHelper类的典型用法代码示例。如果您正苦于以下问题:Java OptionHelper类的具体用法?Java OptionHelper怎么用?Java OptionHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OptionHelper类属于ch.qos.logback.core.util包,在下文中一共展示了OptionHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileAppender
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private Appender<ILoggingEvent> fileAppender(LogbackConfigurator config,
String logFile) {
RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<ILoggingEvent>();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
String logPattern = this.patterns.getProperty("file", FILE_LOG_PATTERN);
encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext()));
appender.setEncoder(encoder);
config.start(encoder);
appender.setFile(logFile);
FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
rollingPolicy.setFileNamePattern(logFile + ".%i");
appender.setRollingPolicy(rollingPolicy);
rollingPolicy.setParent(appender);
config.start(rollingPolicy);
SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setMaxFileSize("10MB");
appender.setTriggeringPolicy(triggeringPolicy);
config.start(triggeringPolicy);
config.appender("FILE", appender);
return appender;
}
示例2: createConverter
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
* Attempt to create a converter using the information found in
* 'converterMap'.
*
* @param kn
* @return
*/
@SuppressWarnings("unchecked")
DynamicConverter<E> createConverter(SimpleKeywordNode kn) {
String keyword = (String) kn.getValue();
String converterClassStr = (String) converterMap.get(keyword);
if (converterClassStr != null) {
try {
return (DynamicConverter) OptionHelper.instantiateByClassName(
converterClassStr, DynamicConverter.class, context);
} catch (Exception e) {
addError("Failed to instantiate converter class [" + converterClassStr
+ "] for keyword ["+keyword+"]", e);
return null;
}
} else {
addError("There is no conversion class registered for conversion word ["
+ keyword + "]");
return null;
}
}
示例3: createCompositeConverter
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
* Attempt to create a converter using the information found in
* 'compositeConverterMap'.
*
* @param cn
* @return
*/
@SuppressWarnings("unchecked")
CompositeConverter<E> createCompositeConverter(CompositeNode cn) {
String keyword = (String) cn.getValue();
String converterClassStr = (String) converterMap.get(keyword);
if (converterClassStr != null) {
try {
return (CompositeConverter) OptionHelper.instantiateByClassName(
converterClassStr, CompositeConverter.class, context);
} catch (Exception e) {
addError("Failed to instantiate converter class [" + converterClassStr
+ "] as a composite converter for keyword ["+keyword+"]", e);
return null;
}
} else {
addError("There is no conversion class registered for composite conversion word ["
+ keyword + "]");
return null;
}
}
示例4: lookupKey
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private String lookupKey(String key) {
String value = propertyContainer0.getProperty(key);
if (value != null)
return value;
if (propertyContainer1 != null) {
value = propertyContainer1.getProperty(key);
if (value != null)
return value;
}
value = OptionHelper.getSystemProperty(key, null);
if (value != null)
return value;
value = OptionHelper.getEnv(key);
if (value != null) {
return value;
}
return null;
}
示例5: getInputURL
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
URL getInputURL(InterpretationContext ec, Attributes attributes) {
String fileAttribute = attributes.getValue(FILE_ATTR);
String urlAttribute = attributes.getValue(URL_ATTR);
String resourceAttribute = attributes.getValue(RESOURCE_ATTR);
if (!OptionHelper.isEmpty(fileAttribute)) {
this.attributeInUse = ec.subst(fileAttribute);
return filePathAsURL(attributeInUse);
}
if (!OptionHelper.isEmpty(urlAttribute)) {
this.attributeInUse = ec.subst(urlAttribute);
return attributeToURL(attributeInUse);
}
if (!OptionHelper.isEmpty(resourceAttribute)) {
this.attributeInUse = ec.subst(resourceAttribute);
return resourceAsURL(attributeInUse);
}
// given previous checkAttributes() check we cannot reach this line
throw new IllegalStateException("A URL stream should have been returned");
}
示例6: enabledProtocols
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
* Gets the set of enabled protocols based on the configuration.
* @param supportedProtocols protocols supported by the SSL engine
* @param defaultProtocols default protocols enabled by the SSL engine
* @return enabled protocols
*/
private String[] enabledProtocols(String[] supportedProtocols,
String[] defaultProtocols) {
if (enabledProtocols == null) {
// we're assuming that the same engine is used for all configurables
// so once we determine the enabled set, we won't do it again
if (OptionHelper.isEmpty(getIncludedProtocols())
&& OptionHelper.isEmpty(getExcludedProtocols())) {
enabledProtocols = Arrays.copyOf(defaultProtocols,
defaultProtocols.length);
}
else {
enabledProtocols = includedStrings(supportedProtocols,
getIncludedProtocols(), getExcludedProtocols());
}
for (String protocol : enabledProtocols) {
addInfo("enabled protocol: " + protocol);
}
}
return enabledProtocols;
}
示例7: enabledCipherSuites
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
* Gets the set of enabled cipher suites based on the configuration.
* @param supportedCipherSuites cipher suites supported by the SSL engine
* @param defaultCipherSuites default cipher suites enabled by the SSL engine
* @return enabled cipher suites
*/
private String[] enabledCipherSuites(String[] supportedCipherSuites,
String[] defaultCipherSuites) {
if (enabledCipherSuites == null) {
// we're assuming that the same engine is used for all configurables
// so once we determine the enabled set, we won't do it again
if (OptionHelper.isEmpty(getIncludedCipherSuites())
&& OptionHelper.isEmpty(getExcludedCipherSuites())) {
enabledCipherSuites = Arrays.copyOf(defaultCipherSuites,
defaultCipherSuites.length);
}
else {
enabledCipherSuites = includedStrings(supportedCipherSuites,
getIncludedCipherSuites(), getExcludedCipherSuites());
}
for (String cipherSuite : enabledCipherSuites) {
addInfo("enabled cipher suite: " + cipherSuite);
}
}
return enabledCipherSuites;
}
示例8: processScanAttrib
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
void processScanAttrib(InterpretationContext ic, Attributes attributes) {
String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
if (!OptionHelper.isEmpty(scanAttrib)
&& !"false".equalsIgnoreCase(scanAttrib)) {
ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
rocf.setContext(context);
String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
try {
Duration duration = Duration.valueOf(scanPeriodAttrib);
rocf.setRefreshPeriod(duration.getMilliseconds());
addInfo("Setting ReconfigureOnChangeFilter scanning period to "
+ duration);
} catch (NumberFormatException nfe) {
addError("Error while converting [" + scanAttrib + "] to long", nfe);
}
}
rocf.start();
LoggerContext lc = (LoggerContext) context;
addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
lc.addTurboFilter(rocf);
}
}
示例9: init
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
* FOR INTERNAL USE. This method is intended for use by StaticLoggerBinder.
*
* @param defaultLoggerContext
* @throws ClassNotFoundException
* @throws NoSuchMethodException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
public void init(LoggerContext defaultLoggerContext, Object key) throws ClassNotFoundException,
NoSuchMethodException, InstantiationException, IllegalAccessException,
InvocationTargetException {
if(this.key == null) {
this.key = key;
} else if (this.key != key) {
throw new IllegalAccessException("Only certain classes can access this method.");
}
String contextSelectorStr = OptionHelper
.getSystemProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR);
if (contextSelectorStr == null) {
contextSelector = new DefaultContextSelector(defaultLoggerContext);
} else if (contextSelectorStr.equals("JNDI")) {
// if jndi is specified, let's use the appropriate class
contextSelector = new ContextJNDISelector(defaultLoggerContext);
} else {
contextSelector = dynamicalContextSelector(defaultLoggerContext,
contextSelectorStr);
}
}
示例10: begin
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
public void begin(InterpretationContext ic, String name, Attributes attributes) {
String valueStr = attributes.getValue(VALUE_ATR);
if (OptionHelper.isEmpty(valueStr)) {
ic.addError("The literal action requires a value attribute");
return;
}
try {
Integer i = Integer.valueOf(valueStr);
ic.pushObject(i);
} catch (NumberFormatException nfe) {
ic.addError("The value [" + valueStr
+ "] could not be converted to an Integer", nfe);
throw nfe;
}
}
示例11: begin
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes) {
// See LBCLASSIC-225 (the system property is looked up first. Thus, it overrides
// the equivalent property in the config file. This reversal of scope priority is justified
// by the use case: the admin trying to chase rogue config file
String debugAttrib = System.getProperty(DEBUG_SYSTEM_PROPERTY_KEY);
if (debugAttrib == null) {
debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
}
if (OptionHelper.isEmpty(debugAttrib) || debugAttrib.equals("false") || debugAttrib.equals("null")) {
addInfo(INTERNAL_DEBUG_ATTR + " attribute not set");
} else {
OnConsoleStatusListener.addNewInstanceToContext(context);
}
new ContextUtil(context).addHostNameAsProperty();
// the context is appender attachable, so it is pushed on top of the stack
ec.pushObject(getContext());
}
示例12: start
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
@Override
public void start() throws LifecycleException {
super.start();
ctx.start();
if (filename == null) {
filename = OptionHelper.getSystemProperty("logbackAccess.configurationFile");
if (filename == null) {
filename = DEFAULT_CONFIG_FILE;
}
ctx.getStatusManager().add(new InfoStatus("filename property not set. Assuming [" + filename + "]", this));
}
// TODO: Support classpath config
File configFile = new File(filename);
if (configFile.exists()) {
try {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(ctx);
jc.doConfigure(filename);
} catch (JoranException e) {
// TODO can we do better than printing a stack trace on syserr?
e.printStackTrace();
}
} else {
ctx.getStatusManager().add(new WarnStatus("[" + filename + "] does not exist", this));
}
if (!quiet) {
StatusPrinter.print(ctx.getStatusManager());
}
}
示例13: init
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
public void init(KonkerLoggerContext defaultLoggerContext, Object key) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
if(this.key == null) {
this.key = key;
} else if(this.key != key) {
throw new IllegalAccessException("Only certain classes can access this method.");
}
String contextSelectorStr = OptionHelper.getSystemProperty("logback.ContextSelector");
if(contextSelectorStr == null) {
this.contextSelector = new KonkerDefaultContextSelector(defaultLoggerContext);
} else {
this.contextSelector = dynamicalContextSelector(defaultLoggerContext, contextSelectorStr);
}
}
示例14: installIfAsked
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
static void installIfAsked(KonkerLoggerContext loggerContext) {
String slClass = OptionHelper.getSystemProperty("logback.statusListenerClass");
if(!OptionHelper.isEmpty(slClass)) {
addStatusListener(loggerContext, slClass);
}
}
示例15: createListenerPerClassName
import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private static StatusListener createListenerPerClassName(KonkerLoggerContext loggerContext,
String listenerClass) {
try {
return (StatusListener)OptionHelper.instantiateByClassName(listenerClass, StatusListener.class, loggerContext);
} catch (Exception var3) {
var3.printStackTrace();
return null;
}
}