use of ch.qos.logback.core.FileAppender in project sonarqube by SonarSource.
the class CeProcessLoggingTest method log_to_ce_file.
@Test
public void log_to_ce_file() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME);
Appender<ILoggingEvent> appender = root.getAppender("file_ce");
assertThat(appender).isInstanceOf(FileAppender.class);
FileAppender fileAppender = (FileAppender) appender;
assertThat(fileAppender.getFile()).isEqualTo(new File(logDir, "ce.log").getAbsolutePath());
assertThat(fileAppender.getEncoder()).isInstanceOf(PatternLayoutEncoder.class);
PatternLayoutEncoder encoder = (PatternLayoutEncoder) fileAppender.getEncoder();
assertThat(encoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level ce[%X{ceTaskUuid}][%logger{20}] %msg%n");
}
use of ch.qos.logback.core.FileAppender in project sonarqube by SonarSource.
the class SearchLoggingTest method log_to_es_file.
@Test
public void log_to_es_file() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(ROOT_LOGGER_NAME);
Appender<ILoggingEvent> appender = root.getAppender("file_es");
assertThat(appender).isInstanceOf(FileAppender.class);
FileAppender fileAppender = (FileAppender) appender;
assertThat(fileAppender.getFile()).isEqualTo(new File(logDir, "es.log").getAbsolutePath());
assertThat(fileAppender.getEncoder()).isInstanceOf(PatternLayoutEncoder.class);
PatternLayoutEncoder encoder = (PatternLayoutEncoder) fileAppender.getEncoder();
assertThat(encoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level es[][%logger{20}] %msg%n");
}
use of ch.qos.logback.core.FileAppender in project sling by apache.
the class SlingLogPanel method renderAppenderContent.
private void renderAppenderContent(LoggerStateContext ctx, PrintWriter pw, String appenderName, TailerOptions opts) throws IOException {
for (final Appender<ILoggingEvent> appender : ctx.appenders.values()) {
if (appender instanceof FileAppender && appenderName.equals(appender.getName())) {
final File file = new File(((FileAppender) appender).getFile());
if (file.exists()) {
if (opts.tailAll()) {
SlingConfigurationPrinter.includeWholeFile(pw, file);
} else {
int numOfLines = opts.getNumOfLines();
if (numOfLines == 0) {
numOfLines = logbackManager.getLogConfigManager().getNumOfLines();
}
new Tailer(new FilteringListener(pw, opts.getRegex()), numOfLines).tail(file);
}
}
return;
}
}
pw.printf("No appender with name [%s] found", appenderName);
}
use of ch.qos.logback.core.FileAppender in project sling by apache.
the class LogTailerWebConsolePlugin method getOptions.
private String getOptions() {
Set<String> logFiles = new HashSet<String>();
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); ) {
Appender<ILoggingEvent> appender = index.next();
if (appender instanceof FileAppender) {
FileAppender fileAppender = (FileAppender) appender;
String logfilePath = fileAppender.getFile();
logFiles.add(logfilePath);
}
}
}
String logFilesHtml = "<option value=\"\"> - Select file - </option>";
for (String logFile : logFiles) {
File file = new File(logFile);
logFilesHtml += "<option value=\"" + getKey(file) + "\">" + file.getName() + "</option>";
}
return logFilesHtml;
}
use of ch.qos.logback.core.FileAppender in project qpid-broker-j by apache.
the class RollingPolicyDecoratorTest method testSetParent.
public void testSetParent() {
FileAppender appender = mock(FileAppender.class);
_policy.setParent(appender);
verify(_delegate).setParent(appender);
}
Aggregations