當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncAppender.setQueueSize方法代碼示例

本文整理匯總了Java中ch.qos.logback.classic.AsyncAppender.setQueueSize方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncAppender.setQueueSize方法的具體用法?Java AsyncAppender.setQueueSize怎麽用?Java AsyncAppender.setQueueSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.classic.AsyncAppender的用法示例。


在下文中一共展示了AsyncAppender.setQueueSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender() {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"," +
        "\"instance_id\":\"" + instanceId + "\"}";
    
    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);
    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:xetys,項目名稱:jhipster-ribbon-hystrix,代碼行數:26,代碼來源:LoggingConfiguration.java

示例2: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender(LoggerContext context) {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"," +
        "\"instance_id\":\"" + instanceId + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:33,代碼來源:LoggingConfiguration.java

示例3: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender(LoggerContext context) {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:Microsoft,項目名稱:MTC_Labrat,代碼行數:32,代碼來源:LoggingConfiguration.java

示例4: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
private static void addLogstashAppender(LoggerContext context, XmLogstashConfig config) {
    LOGGER.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + config.getAppName() + "\",\"app_port\":\"" + config.getAppPort()
        + "\",\"instance_id\":\"" + config.getInstanceId() + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(config.getLogstashHost());
    logstashAppender.setPort(config.getLogstashPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(config.getLogstashQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:33,代碼來源:LogstashConfigurer.java

示例5: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
private void addLogstashAppender(LoggerContext context) {
    log.info("Initializing Logstash logging");

    LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
    logstashAppender.setName(LOGSTASH_APPENDER_NAME);
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

    // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
    LogstashEncoder logstashEncoder=new LogstashEncoder();
    // Set the Logstash appender config from JHipster properties
    logstashEncoder.setCustomFields(customFields);
    // Set the Logstash appender config from JHipster properties
    logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(),jHipsterProperties.getLogging().getLogstash().getPort()));

    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setRootCauseFirst(true);
    logstashEncoder.setThrowableConverter(throwableConverter);
    logstashEncoder.setCustomFields(customFields);

    logstashAppender.setEncoder(logstashEncoder);
    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME);
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:pascalgrimaud,項目名稱:qualitoast,代碼行數:34,代碼來源:LoggingConfiguration.java

示例6: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender() {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"," +
        "\"instance_id\":\"" + instanceId + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:IBM,項目名稱:Microservices-with-JHipster-and-Spring-Boot,代碼行數:33,代碼來源:LoggingConfiguration.java

示例7: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender() {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);

    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:klask-io,項目名稱:klask-io,代碼行數:33,代碼來源:LoggingConfiguration.java

示例8: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
private void addLogstashAppender(LoggerContext context) {
    log.info("Initializing Logstash logging");

    LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

    // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
    LogstashEncoder logstashEncoder=new LogstashEncoder();
    // Set the Logstash appender config from JHipster properties
    logstashEncoder.setCustomFields(customFields);
    // Set the Logstash appender config from JHipster properties
    logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(),jHipsterProperties.getLogging().getLogstash().getPort()));

    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setRootCauseFirst(true);
    logstashEncoder.setThrowableConverter(throwableConverter);
    logstashEncoder.setCustomFields(customFields);

    logstashAppender.setEncoder(logstashEncoder);
    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:asanzdiego,項目名稱:codemotion-2017-taller-de-jhipster,代碼行數:34,代碼來源:LoggingConfiguration.java

示例9: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender() {
    log.info("Initializing Logstash logging");

    LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

    // Set the Logstash appender config from JHipster properties
    logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
    logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
    logstashAppender.setCustomFields(customFields);

    // Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setMaxLength(7500);
    throwableConverter.setRootCauseFirst(true);
    logstashAppender.setThrowableConverter(throwableConverter);

    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:mraible,項目名稱:jhipster-stormpath-example,代碼行數:32,代碼來源:LoggingConfiguration.java

示例10: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public void addLogstashAppender(LoggerContext context) {
	log.info("Initializing Logstash logging");

	LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
	logstashAppender.setName("LOGSTASH");
	logstashAppender.setContext(context);
	String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";

	// Set the Logstash appender config from JHipster properties
	logstashAppender.setSyslogHost(jHipsterProperties.getLogging().getLogstash().getHost());
	logstashAppender.setPort(jHipsterProperties.getLogging().getLogstash().getPort());
	logstashAppender.setCustomFields(customFields);

	// Limit the maximum length of the forwarded stacktrace so that it won't exceed the 8KB UDP limit of logstash
	ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
	throwableConverter.setMaxLength(7500);
	throwableConverter.setRootCauseFirst(true);
	logstashAppender.setThrowableConverter(throwableConverter);

	logstashAppender.start();

	// Wrap the appender in an Async appender for performance
	AsyncAppender asyncLogstashAppender = new AsyncAppender();
	asyncLogstashAppender.setContext(context);
	asyncLogstashAppender.setName("ASYNC_LOGSTASH");
	asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
	asyncLogstashAppender.addAppender(logstashAppender);
	asyncLogstashAppender.start();

	context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:alikemalocalan,項目名稱:MicroBlog,代碼行數:32,代碼來源:LoggingConfiguration.java

示例11: addLogstashAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
private void addLogstashAppender(LoggerContext context) {
    log.info("Initializing Logstash logging");

    LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
    logstashAppender.setName("LOGSTASH");
    logstashAppender.setContext(context);
    String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"," +
        "\"instance_id\":\"" + eurekaInstanceConfigBean.getInstanceId() + "\"," + "\"version\":\"" + version + "\"}";

    // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
    LogstashEncoder logstashEncoder=new LogstashEncoder();
    // Set the Logstash appender config from JHipster properties
    logstashEncoder.setCustomFields(customFields);
    // Set the Logstash appender config from JHipster properties
    logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(),jHipsterProperties.getLogging().getLogstash().getPort()));

    ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
    throwableConverter.setRootCauseFirst(true);
    logstashEncoder.setThrowableConverter(throwableConverter);
    logstashEncoder.setCustomFields(customFields);

    logstashAppender.setEncoder(logstashEncoder);
    logstashAppender.start();

    // Wrap the appender in an Async appender for performance
    AsyncAppender asyncLogstashAppender = new AsyncAppender();
    asyncLogstashAppender.setContext(context);
    asyncLogstashAppender.setName("ASYNC_LOGSTASH");
    asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
    asyncLogstashAppender.addAppender(logstashAppender);
    asyncLogstashAppender.start();

    context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
 
開發者ID:kalnee,項目名稱:trivor,代碼行數:35,代碼來源:LoggingConfiguration.java

示例12: asAsync

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
protected Appender<ILoggingEvent> asAsync(Appender<ILoggingEvent> appender, Context context) {
    AsyncAppender asyncAppender = new AsyncAppender();
    asyncAppender.setIncludeCallerData(false);
    asyncAppender.setQueueSize(AsyncAppenderBase.DEFAULT_QUEUE_SIZE);
    asyncAppender.setDiscardingThreshold(-1);
    asyncAppender.setContext(context);
    asyncAppender.setName(appender.getName());
    asyncAppender.addAppender(appender);
    asyncAppender.start();
    return asyncAppender;
}
 
開發者ID:bootique,項目名稱:bootique-logback,代碼行數:12,代碼來源:AppenderFactory.java

示例13: createAppender

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
@Override
protected AsyncAppender createAppender(int consumers) {
    AsyncAppender appender = new AsyncAppender();
    appender.setName("async");
    appender.setQueueSize(1048576);
    return appender;
}
 
開發者ID:trautonen,項目名稱:logback-ext,代碼行數:8,代碼來源:AsyncAppenderBenchmark.java

示例14: configureRotatingLogging

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public static void configureRotatingLogging( String baseLoggingDir, String loglevel, String appName ) {
    
    if ( !baseLoggingDir.endsWith( "/" ) ) {
        baseLoggingDir = baseLoggingDir + "/";
    }
    
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    lc.reset();
    Logger rootLogger = getRootLogger( loglevel );
    PatternLayoutEncoder ple = getPatternLayoutEncoder( lc );
    
    String baseAppLoggingDir = baseLoggingDir;
    // set a system property so other loggers write the correct place
    System.setProperty( "krux-base-app-log-dir", baseAppLoggingDir );

    try {
        // Define file appender with layout and output log file name
        RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
        fileAppender.setContext( lc );
        fileAppender.setName( "krux-file-appender" );
        fileAppender.setFile( baseAppLoggingDir + appName + ".log" );
        fileAppender.setAppend( true );
        fileAppender.setEncoder( ple );
        
        FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
        rollingPolicy.setContext( lc );
        rollingPolicy.setMinIndex( 1 );
        rollingPolicy.setMaxIndex( 9 );
        rollingPolicy.setFileNamePattern( baseAppLoggingDir + appName + ".%i.log.gz" );
        rollingPolicy.setParent( fileAppender );
        rollingPolicy.start();
        
        SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>( "100MB" );
        triggeringPolicy.setContext( lc );
        triggeringPolicy.start();

        fileAppender.setRollingPolicy( rollingPolicy );
        fileAppender.setTriggeringPolicy( triggeringPolicy );
        fileAppender.start();

        // Wrap the console appenders in an async appenders
        AsyncAppender asyncOut = new AsyncAppender();
        asyncOut.setContext( lc );
        asyncOut.setDiscardingThreshold( 0 );
        asyncOut.setQueueSize( 500 );
        asyncOut.addAppender( fileAppender );
        asyncOut.setName( "stdlib-async-out" );
        asyncOut.start();

        // Add the appender to root logger
        rootLogger.addAppender( asyncOut );
        
        // wrap stdout & stderr in log4j appenders 
        StdOutErrLog.tieSystemOutAndErrToLog();
        
    } catch ( Exception e ) {
        System.out.println( "Failed to add appender !!" );
        e.printStackTrace();
    }

}
 
開發者ID:krux,項目名稱:java-stdlib,代碼行數:62,代碼來源:LoggerConfigurator.java

示例15: configureStdOutLogging

import ch.qos.logback.classic.AsyncAppender; //導入方法依賴的package包/類
public static void configureStdOutLogging( String loglevel ) {

        if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
            System.err.println("Logger is not using logback, skipping logging configuration");
            return;
        }

        try {
            LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
            lc.reset();
            Logger rootLogger = getRootLogger( loglevel );
            PatternLayoutEncoder ple = getPatternLayoutEncoder( lc );

            // ops would like us to log to console unless an app
            // has a specific need not to
            ConsoleAppender<ILoggingEvent> stdOutAppender = new ConsoleAppender<ILoggingEvent>();
            stdOutAppender.setContext( lc );
            stdOutAppender.setName( "stdlib-console-out" );
            stdOutAppender.setTarget( "System.out" );
            stdOutAppender.setEncoder( ple );
            
            Filter<ILoggingEvent> stdOutFilter = new StdOutFilter();
            stdOutAppender.addFilter( stdOutFilter );
            stdOutFilter.start();
            stdOutAppender.start();

            ple = getPatternLayoutEncoder( lc );
            
            ConsoleAppender<ILoggingEvent> errorAppender = new ConsoleAppender<ILoggingEvent>();
            errorAppender.setContext( lc );
            errorAppender.setName( "stdlib-console-err" );
            errorAppender.setTarget( "System.err" );
            errorAppender.setEncoder( ple );
            
            Filter<ILoggingEvent> stdErrFilter = new ErrOutFilter();
            errorAppender.addFilter( stdErrFilter );
            stdErrFilter.start();
            errorAppender.start();

            // Wrap the console appenders in an async appenders
            AsyncAppender asyncStdOutWrapper = new AsyncAppender();
            asyncStdOutWrapper.setContext( lc );
            asyncStdOutWrapper.setDiscardingThreshold( 0 );
            asyncStdOutWrapper.setQueueSize( 500 );
            asyncStdOutWrapper.addAppender( stdOutAppender );
            asyncStdOutWrapper.setName( "stdlib-async-out" );
            asyncStdOutWrapper.start();
            
            // Wrap the console appenders in an async appenders
            AsyncAppender asyncStdErrWrapper = new AsyncAppender();
            asyncStdErrWrapper.setContext( lc );
            asyncStdErrWrapper.setDiscardingThreshold( 0 );
            asyncStdErrWrapper.setQueueSize( 500 );
            asyncStdErrWrapper.addAppender( errorAppender ); 
            asyncStdErrWrapper.setName( "stdlib-async-err-2" );
            asyncStdErrWrapper.start();

            // Add the appenders to root logger
            rootLogger.addAppender( asyncStdOutWrapper );
            rootLogger.addAppender( asyncStdErrWrapper );

        } catch ( Exception e ) {
            System.err.println( "Failed to add appender!!" );
            e.printStackTrace();
        }

        // wrap stdout & stderr in log4j appenders 
        StdOutErrLog.tieSystemOutAndErrToLog();

    }
 
開發者ID:krux,項目名稱:java-stdlib,代碼行數:71,代碼來源:LoggerConfigurator.java


注:本文中的ch.qos.logback.classic.AsyncAppender.setQueueSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。