use of ch.qos.logback.core.Appender in project sonarqube by SonarSource.
the class SearchLoggingTest method do_not_log_to_console.
@Test
public void do_not_log_to_console() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(ROOT_LOGGER_NAME);
Appender appender = root.getAppender("CONSOLE");
assertThat(appender).isNull();
}
use of ch.qos.logback.core.Appender in project sling by apache.
the class ITDefaultConfig method testDefaultSettings.
/**
* Checks the default settings. It runs the bundle with minimum dependencies
*/
@Test
public void testDefaultSettings() throws Exception {
Logger slf4jLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
assertTrue("Default Log level should be INFO", slf4jLogger.isInfoEnabled());
// Check for Logback being used
assertTrue(LoggerFactory.getILoggerFactory() instanceof LoggerContext);
assertTrue(slf4jLogger instanceof ch.qos.logback.classic.Logger);
// Test that root logger has one FileAppender attached
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) slf4jLogger;
Iterator<Appender<ILoggingEvent>> itr = logger.iteratorForAppenders();
assertTrue("One appender should be attached with root logger", itr.hasNext());
}
use of ch.qos.logback.core.Appender in project sling by apache.
the class ITConfigAdminSupport method testChangeLogLevelWithConfig.
@Test
public void testChangeLogLevelWithConfig() throws Exception {
// Set log level to debug for foo1.bar
Configuration config = ca.createFactoryConfiguration(FACTORY_PID_CONFIGS, null);
Dictionary<String, Object> p = new Hashtable<String, Object>();
p.put(LOG_LOGGERS, new String[] { "foo1.bar" });
p.put(LOG_LEVEL, "DEBUG");
config.update(p);
delay();
Logger slf4jLogger = LoggerFactory.getLogger("foo1.bar");
assertTrue(slf4jLogger.isDebugEnabled());
assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isInfoEnabled());
assertFalse(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled());
// foo1.bar should not have explicit appender attached with it
Iterator<Appender<ILoggingEvent>> itr = ((ch.qos.logback.classic.Logger) slf4jLogger).iteratorForAppenders();
assertFalse(itr.hasNext());
}
use of ch.qos.logback.core.Appender in project uavstack by uavorg.
the class LogBackHookProxy method figureoutLogConfiguration.
private void figureoutLogConfiguration(Logger Logger, LinkedList<LogProfileInfo> list, String appid) {
Iterator<Appender<ILoggingEvent>> appenders = Logger.iteratorForAppenders();
while (appenders != null && appenders.hasNext()) {
LogProfileInfo logProfileInfo = new LogProfileInfo();
if (appid != null) {
logProfileInfo.setAppId(appid);
}
logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(LogProfileInfo.ENGINE, "logback");
Appender<ILoggingEvent> appender = appenders.next();
if (!(appender instanceof FileAppender<?>)) {
continue;
}
FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) appender;
@SuppressWarnings("rawtypes") LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder();
Layout<?> layout = encoder.getLayout();
if (null != layout) {
if (layout instanceof PatternLayout) {
PatternLayout patternLayout = (PatternLayout) encoder.getLayout();
attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern());
} else if (layout instanceof HTMLLayout) {
attributes.put(LogProfileInfo.PATTERN, "HTMLLayout");
} else if (layout instanceof XMLLayout) {
attributes.put(LogProfileInfo.PATTERN, "XMLLayout");
} else if (layout instanceof TTLLLayout) {
attributes.put(LogProfileInfo.PATTERN, "TTCCLayout");
}
}
logProfileInfo.setFilePath(fileAppender.getFile());
logProfileInfo.setAttributes(attributes);
list.add(logProfileInfo);
}
}
use of ch.qos.logback.core.Appender in project qpid-broker-j by apache.
the class QpidBrokerTestCase method getFileFromSiftingAppender.
private File getFileFromSiftingAppender(final ch.qos.logback.classic.Logger logger) {
String key = logger.getLoggerContext().getProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME);
for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); ) /* do nothing */
{
Appender<ILoggingEvent> appender = index.next();
if (appender instanceof SiftingAppender) {
SiftingAppender siftingAppender = (SiftingAppender) appender;
Appender subAppender = siftingAppender.getAppenderTracker().find(key);
if (subAppender instanceof FileAppender) {
return new File(((FileAppender) subAppender).getFile());
}
}
}
return null;
}
Aggregations