use of ch.qos.logback.classic.filter.ThresholdFilter in project AJSC by att.
the class loggingConfigurationTest method getThresholdFilterInstanceTest.
@Test
public void getThresholdFilterInstanceTest() {
System.out.println("Running getThresholdFilterInstanceTest");
LoggingConfigurationService l = new LoggingConfigurationService();
l.init();
ThresholdFilter tf = (ThresholdFilter) l.getThresholdFilterInstance();
assertEquals("ch.qos.logback.classic.filter.ThresholdFilter", tf.getClass().getName());
}
use of ch.qos.logback.classic.filter.ThresholdFilter in project dropwizard by dropwizard.
the class ThresholdLevelFilterFactory method build.
/**
* Creates and starts a {@link Filter} for the given threshold.
* @param threshold The minimum event level for this filter.
* @return a new, started {@link Filter}
*/
@Override
public Filter<ILoggingEvent> build(Level threshold) {
final ThresholdFilter filter = new ThresholdFilter();
filter.setLevel(threshold.toString());
filter.start();
return filter;
}
use of ch.qos.logback.classic.filter.ThresholdFilter in project Terasology by MovingBlocks.
the class TelemetryLogstashAppender method addErrorFilter.
private void addErrorFilter() {
ThresholdFilter filter = new ThresholdFilter();
filter.setLevel("error");
filter.start();
this.addFilter(filter);
}
use of ch.qos.logback.classic.filter.ThresholdFilter in project dropwizard by dropwizard.
the class BootstrapLogging method bootstrap.
public static void bootstrap(Level level) {
LoggingUtil.hijackJDKLogging();
BOOTSTRAPPING_LOCK.lock();
try {
if (bootstrapped) {
return;
}
final Logger root = LoggingUtil.getLoggerContext().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
root.detachAndStopAllAppenders();
final DropwizardLayout formatter = new DropwizardLayout(root.getLoggerContext(), TimeZone.getDefault());
formatter.start();
final ThresholdFilter filter = new ThresholdFilter();
filter.setLevel(level.toString());
filter.start();
final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
appender.addFilter(filter);
appender.setContext(root.getLoggerContext());
final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder = new LayoutWrappingEncoder<>();
layoutEncoder.setLayout(formatter);
appender.setEncoder(layoutEncoder);
appender.start();
root.addAppender(appender);
bootstrapped = true;
} finally {
BOOTSTRAPPING_LOCK.unlock();
}
}
use of ch.qos.logback.classic.filter.ThresholdFilter in project ANNIS by korpling.
the class AnnisBaseRunner method setupLogging.
// configure logging
public static void setupLogging(boolean console) {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(loggerContext);
loggerContext.reset();
try {
jc.doConfigure(System.getProperty("annis.home") + "/conf/logback.xml");
} catch (JoranException ex) {
System.out.println(ex.getMessage());
}
ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
consoleAppender.setContext(loggerContext);
consoleAppender.setName("CONSOLE");
consoleAppender.setLayout(new ConsoleLayout());
ThresholdFilter consoleFilter = new ConsoleFilter();
consoleFilter.setLevel(console ? "DEBUG" : "WARN");
consoleFilter.start();
consoleAppender.addFilter(consoleFilter);
consoleAppender.setTarget("System.err");
consoleAppender.start();
ch.qos.logback.classic.Logger logbackLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
logbackLogger.addAppender(consoleAppender);
SLF4JBridgeHandler.removeHandlersForRootLogger();
;
SLF4JBridgeHandler.install();
}
Aggregations