Search in sources :

Example 1 with Tailer

use of org.apache.commons.io.input.Tailer in project cas by apereo.

the class LoggingOutputSocketMessagingController method registerLogFileTailThreads.

private void registerLogFileTailThreads() throws IOException {
    final Collection<String> outputFileNames = new HashSet<>();
    final Collection<Appender> loggerAppenders = this.loggerContext.getConfiguration().getAppenders().values();
    loggerAppenders.forEach(appender -> {
        if (appender instanceof FileAppender) {
            outputFileNames.add(((FileAppender) appender).getFileName());
        } else if (appender instanceof RandomAccessFileAppender) {
            outputFileNames.add(((RandomAccessFileAppender) appender).getFileName());
        } else if (appender instanceof RollingFileAppender) {
            outputFileNames.add(((RollingFileAppender) appender).getFileName());
        } else if (appender instanceof MemoryMappedFileAppender) {
            outputFileNames.add(((MemoryMappedFileAppender) appender).getFileName());
        } else if (appender instanceof RollingRandomAccessFileAppender) {
            outputFileNames.add(((RollingRandomAccessFileAppender) appender).getFileName());
        }
    });
    outputFileNames.forEach(s -> {
        final Tailer t = new Tailer(new File(s), new LogTailerListener(), 100, false, true);
        final Thread thread = new Thread(t);
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.setName(s);
        thread.start();
    });
}
Also used : RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) Appender(org.apache.logging.log4j.core.Appender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) Tailer(org.apache.commons.io.input.Tailer) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) File(java.io.File) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) HashSet(java.util.HashSet)

Example 2 with Tailer

use of org.apache.commons.io.input.Tailer in project cas by apereo.

the class LoggingOutputTailingService method registerLogFileTailersForExecution.

private void registerLogFileTailersForExecution(final LoggerContext loggerContext) {
    final Collection<String> outputFileNames = new HashSet<>();
    final Collection<Appender> loggerAppenders = loggerContext.getConfiguration().getAppenders().values();
    loggerAppenders.forEach(appender -> {
        if (appender instanceof FileAppender) {
            outputFileNames.add(FileAppender.class.cast(appender).getFileName());
        } else if (appender instanceof RandomAccessFileAppender) {
            outputFileNames.add(RandomAccessFileAppender.class.cast(appender).getFileName());
        } else if (appender instanceof RollingFileAppender) {
            outputFileNames.add(RollingFileAppender.class.cast(appender).getFileName());
        } else if (appender instanceof MemoryMappedFileAppender) {
            outputFileNames.add(MemoryMappedFileAppender.class.cast(appender).getFileName());
        } else if (appender instanceof RollingRandomAccessFileAppender) {
            outputFileNames.add(RollingRandomAccessFileAppender.class.cast(appender).getFileName());
        }
    });
    outputFileNames.forEach(f -> {
        final Tailer t = new Tailer(new File(f), this, 100L, false, true);
        this.tailers.add(t);
        this.taskExecutor.execute(t);
    });
}
Also used : RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) Appender(org.apache.logging.log4j.core.Appender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) Tailer(org.apache.commons.io.input.Tailer) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) File(java.io.File) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) HashSet(java.util.HashSet)

Example 3 with Tailer

use of org.apache.commons.io.input.Tailer in project spring-integration by spring-projects.

the class ApacheCommonsFileTailingMessageProducer method doStart.

@Override
protected void doStart() {
    super.doStart();
    Tailer tailer = new Tailer(this.getFile(), this, this.pollingDelay, this.end, this.reopen);
    this.getTaskExecutor().execute(tailer);
    this.tailer = tailer;
}
Also used : Tailer(org.apache.commons.io.input.Tailer)

Example 4 with Tailer

use of org.apache.commons.io.input.Tailer in project solr-cmd-utils by tblsoft.

the class Test method tailer.

@org.junit.Test
@Ignore
public void tailer() throws Exception {
    TailerListener listener = new MyTailerListener();
    Tailer tailer = Tailer.create(new File("/tmp/artifacts/solr.log"), listener, 1000, true);
    tailer.run();
}
Also used : Tailer(org.apache.commons.io.input.Tailer) File(java.io.File) TailerListener(org.apache.commons.io.input.TailerListener) Ignore(org.junit.Ignore)

Example 5 with Tailer

use of org.apache.commons.io.input.Tailer in project app-maven-plugin by GoogleCloudPlatform.

the class TailingVerifier method startTailingLog.

private void startTailingLog() {
    TailerListener listener = new TailerListenerAdapter() {

        @Override
        public void handle(String line) {
            System.out.println(testName + ": " + line);
        }
    };
    // Tail the log
    File file = new File(getBasedir() + File.separator + getLogFileName());
    try {
        if (file.exists()) {
            file.delete();
        }
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Tailer tailer = new Tailer(file, listener, TAIL_DELAY_MILLIS);
    Thread thread = new Thread(tailer);
    thread.setDaemon(true);
    thread.start();
}
Also used : Tailer(org.apache.commons.io.input.Tailer) IOException(java.io.IOException) TailerListenerAdapter(org.apache.commons.io.input.TailerListenerAdapter) File(java.io.File) TailerListener(org.apache.commons.io.input.TailerListener)

Aggregations

Tailer (org.apache.commons.io.input.Tailer)6 File (java.io.File)4 HashSet (java.util.HashSet)2 TailerListener (org.apache.commons.io.input.TailerListener)2 Appender (org.apache.logging.log4j.core.Appender)2 FileAppender (org.apache.logging.log4j.core.appender.FileAppender)2 MemoryMappedFileAppender (org.apache.logging.log4j.core.appender.MemoryMappedFileAppender)2 RandomAccessFileAppender (org.apache.logging.log4j.core.appender.RandomAccessFileAppender)2 RollingFileAppender (org.apache.logging.log4j.core.appender.RollingFileAppender)2 RollingRandomAccessFileAppender (org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender)2 IOException (java.io.IOException)1 TailerListenerAdapter (org.apache.commons.io.input.TailerListenerAdapter)1 ServerLogPatternListener (org.jboss.additional.testsuite.jdkall.present.shared.ServerLogPatternListener)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1