Package org.apache.log4j

Examples of org.apache.log4j.AsyncAppender$Dispatcher


* Created by Tronok on 29.04.14.
*/
public class DispatcherTest {
    @Test
    public void testDispatcherNormal2Threads() throws InterruptedException, ExecutionException, IOException {
        Dispatcher dispatcher = new Dispatcher("multicoreTest.txt", 2);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
        dispatcher = new Dispatcher("multicoreTest_1_by_1.txt", 2);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
    }
View Full Code Here


        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
    }

    @Test
    public void testDispatcherNormal3Threads() throws InterruptedException, ExecutionException, IOException {
        Dispatcher dispatcher = new Dispatcher("multicoreTest.txt", 3);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
        dispatcher = new Dispatcher("multicoreTest_1_by_1.txt", 3);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
    }
View Full Code Here

        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
    }

    @Test
    public void testDispatcherNormal4Threads() throws InterruptedException, ExecutionException, IOException {
        Dispatcher dispatcher = new Dispatcher("multicoreTest.txt", 4);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
        dispatcher = new Dispatcher("multicoreTest_1_by_1.txt", 4);
        Assert.assertArrayEquals(new int[]{1, 2, 2, 3, 5, 5, 6, 8, 9, 34}, dispatcher.sort());
    }
View Full Code Here

    //
    //  wrap SyslogAppender with an Async since appender may
    //    hang if syslogd is not accepting network messages
    //
    AsyncAppender asyncAppender = new AsyncAppender();
    asyncAppender.addAppender(appender);
    asyncAppender.activateOptions();

    Logger logger = Logger.getRootLogger();
    logger.addAppender(asyncAppender);

    Exception e =
View Full Code Here

    Logger logger = ((Log4JLogger)auditLog).getLogger();
    @SuppressWarnings("unchecked")
    List<Appender> appenders = Collections.list(logger.getAllAppenders());
    // failsafe against trying to async it more than once
    if (!appenders.isEmpty() && !(appenders.get(0) instanceof AsyncAppender)) {
      AsyncAppender asyncAppender = new AsyncAppender();
      // change logger to have an async appender containing all the
      // previously configured appenders
      for (Appender appender : appenders) {
        logger.removeAppender(appender);
        asyncAppender.addAppender(appender);
      }
      logger.addAppender(asyncAppender);       
    }
  }
View Full Code Here

    public void initLoggingFile() {

            // Base appender
            if (this.baseAppender == null) {
                this.baseAppender = new AsyncAppender();
                this.baseAppender.setBufferSize(1000);
                this.baseAppender.setBlocking(true);
                this.log.addAppender(this.baseAppender);
            }
View Full Code Here

    dst.setThreshold(Level.INFO);
    dst.setErrorHandler(new DieErrorHandler());
    dst.activateOptions();
    dst.setErrorHandler(new LogLogHandler());

    async = new AsyncAppender();
    async.setBlocking(true);
    async.setBufferSize(config.getInt("core", "asyncLoggingBufferSize", 64));
    async.setLocationInfo(false);
    async.addAppender(dst);
    async.activateOptions();
View Full Code Here

    Logger logger = ((Log4JLogger)auditLog).getLogger();
    @SuppressWarnings("unchecked")
    List<Appender> appenders = Collections.list(logger.getAllAppenders());
    // failsafe against trying to async it more than once
    if (!appenders.isEmpty() && !(appenders.get(0) instanceof AsyncAppender)) {
      AsyncAppender asyncAppender = new AsyncAppender();
      // change logger to have an async appender containing all the
      // previously configured appenders
      for (Appender appender : appenders) {
        logger.removeAppender(appender);
        asyncAppender.addAppender(appender);
      }
      logger.addAppender(asyncAppender);       
    }
  }
View Full Code Here

    //
    //  wrap SyslogAppender with an Async since appender may
    //    hang if syslogd is not accepting network messages
    //
    AsyncAppender asyncAppender = new AsyncAppender();
    asyncAppender.addAppender(appender);
    asyncAppender.activateOptions();

    Logger logger = Logger.getRootLogger();
    logger.addAppender(asyncAppender);

    Exception e =
View Full Code Here

    Logger logger = ((Log4JLogger)auditLog).getLogger();
    @SuppressWarnings("unchecked")
    List<Appender> appenders = Collections.list(logger.getAllAppenders());
    // failsafe against trying to async it more than once
    if (!appenders.isEmpty() && !(appenders.get(0) instanceof AsyncAppender)) {
      AsyncAppender asyncAppender = new AsyncAppender();
      // change logger to have an async appender containing all the
      // previously configured appenders
      for (Appender appender : appenders) {
        logger.removeAppender(appender);
        asyncAppender.addAppender(appender);
      }
      logger.addAppender(asyncAppender);       
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.log4j.AsyncAppender$Dispatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.