use of ch.qos.logback.classic.Logger in project springside4 by springside.
the class LogbackListAppender method addToLogger.
/**
* 将此appender添加到logger中.
*/
public void addToLogger(String loggerName) {
Logger logger = (Logger) LoggerFactory.getLogger(loggerName);
logger.addAppender(this);
}
use of ch.qos.logback.classic.Logger in project springside4 by springside.
the class LogbackListAppender method removeFromLogger.
/**
* 将此appender从logger中移除.
*/
public void removeFromLogger(Class<?> loggerClass) {
Logger logger = (Logger) LoggerFactory.getLogger(loggerClass);
logger.detachAppender(this);
}
use of ch.qos.logback.classic.Logger in project gocd by gocd.
the class FileLocationProvider method asJson.
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
json.put("loc.config.dir", systemEnvironment.configDir().getAbsolutePath());
List<Logger> loggers = LOGGER_CONTEXT.getLoggerList();
Appender[] appenders = getAppenders(loggers);
for (int i = 0; i < appenders.length; i++) {
Appender appender = appenders[i];
if (!isFileAppender(appender)) {
continue;
}
FileAppender fileAppender = (FileAppender) appender;
File logFile = new File(fileAppender.rawFileProperty());
json.put("loc.log.root." + i, new File(logFile.getAbsolutePath()).getParent());
json.put("loc.log.basename." + i, logFile.getName());
}
return json;
}
use of ch.qos.logback.classic.Logger in project drools-wb by kiegroup.
the class IndexGlobalsInvalidDrlTest method testIndexGlobalsInvalidDrl.
@Test
@SuppressWarnings("unchecked")
public void testIndexGlobalsInvalidDrl() throws IOException, InterruptedException {
// Setup logging
final Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
final Appender<ILoggingEvent> mockAppender = mock(Appender.class);
when(mockAppender.getName()).thenReturn("MOCK");
root.addAppender(mockAppender);
// Add test file
final Path path = basePath.resolve("bz1269366.gdrl");
final String drl = loadText("bz1269366.gdrl");
ioService().write(path, drl);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.util.ArrayList", ResourceType.JAVA)).build();
searchFor(index, query, 0);
verify(mockAppender).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
@Override
public boolean matches(final Object argument) {
return ((ILoggingEvent) argument).getMessage().startsWith("Unable to parse DRL");
}
}));
}
}
use of ch.qos.logback.classic.Logger in project drools-wb by kiegroup.
the class IndexDslInvalidDrlTest method testIndexDslInvalidDrl.
@Test
public void testIndexDslInvalidDrl() throws IOException, InterruptedException {
// Setup logging
final Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
final Appender<ILoggingEvent> mockAppender = mock(Appender.class);
when(mockAppender.getName()).thenReturn("MOCK");
root.addAppender(mockAppender);
// Add test files
final Path path = basePath.resolve("bz1269366.dsl");
final String dsl = loadText("bz1269366.dsl");
ioService().write(path, dsl);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.dsltext.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 0);
verify(mockAppender).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
@Override
public boolean matches(final Object argument) {
return ((ILoggingEvent) argument).getMessage().startsWith("Unable to parse DRL");
}
}));
}
}
Aggregations