use of ch.qos.logback.classic.Logger in project sling by apache.
the class OsgiAppenderRefInternalAction method begin.
@Override
public void begin(InterpretationContext ec, String tagName, Attributes attributes) throws ActionException {
// Let us forget about previous errors (in this object)
inError = false;
Object o = ec.peekObject();
if (!(o instanceof Logger)) {
String errMsg = "Could not find an Logger at the top of execution stack. Near [" + tagName + "] line " + getLineNumber(ec);
inError = true;
addError(errMsg);
return;
}
Logger logger = (Logger) o;
String appenderName = ec.subst(attributes.getValue(ActionConst.REF_ATTRIBUTE));
if (OptionHelper.isEmpty(appenderName)) {
// print a meaningful error message and return
String errMsg = "Missing appender ref attribute in <appender-ref> tag.";
inError = true;
addError(errMsg);
return;
}
@SuppressWarnings("unchecked") Map<String, Set<String>> appenderBag = (Map<String, Set<String>>) ec.getObjectMap().get(OSGI_APPENDER_REF_BAG);
if (appenderBag == null) {
appenderBag = new HashMap<String, Set<String>>();
ec.getObjectMap().put(OSGI_APPENDER_REF_BAG, appenderBag);
}
Set<String> loggers = appenderBag.get(appenderName);
if (loggers == null) {
loggers = new HashSet<String>();
appenderBag.put(appenderName, loggers);
}
loggers.add(logger.getName());
}
use of ch.qos.logback.classic.Logger in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method resetLogging.
@Before
public void resetLogging() {
LoggerContext loggerContext = ((Logger) LoggerFactory.getLogger(getClass())).getLoggerContext();
loggerContext.reset();
new BasicConfigurator().configure(loggerContext);
}
use of ch.qos.logback.classic.Logger in project zipkin by openzipkin.
the class CassandraSpanConsumerTest method clear.
@Before
public void clear() {
storage.clear();
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
when(mockAppender.getName()).thenReturn(CassandraSpanConsumerTest.class.getName());
root.addAppender(mockAppender);
}
use of ch.qos.logback.classic.Logger in project felix by apache.
the class Common method config.
@Configuration
public Option[] config() throws IOException {
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.DEBUG);
return options(cleanCaches(), ipojoBundles(), junitBundles(), testedBundle(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"));
}
use of ch.qos.logback.classic.Logger in project sonarlint-core by SonarSource.
the class SonarLintLogging method setCustomRootAppender.
private static void setCustomRootAppender(Appender<ILoggingEvent> defaultAppender) {
Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
// by default it has an appender logging to stdout
logger.detachAndStopAllAppenders();
appender = new LogCallbackAppender(defaultAppender);
appender.setName(CUSTOM_APPENDER_NAME);
appender.start();
logger.addAppender(appender);
}
Aggregations