当前位置: 首页>>代码示例>>Java>>正文


Java ConsoleAppender.setWriter方法代码示例

本文整理汇总了Java中org.apache.log4j.ConsoleAppender.setWriter方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleAppender.setWriter方法的具体用法?Java ConsoleAppender.setWriter怎么用?Java ConsoleAppender.setWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.ConsoleAppender的用法示例。


在下文中一共展示了ConsoleAppender.setWriter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void main(String[] args) throws TaskExecutionException {

        ConsoleAppender ca = new ConsoleAppender();
        ca.setWriter(new OutputStreamWriter(System.out));
        ca.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
        ca.setThreshold(Level.TRACE);

        logger.getRootLogger().addAppender(ca);

        final MarkLogicMonitor monitor = new MarkLogicMonitor();

        final Map<String, String> taskArgs = new HashMap<String, String>();
        taskArgs.put("config-file", "src/main/resources/conf/config.yml");
        taskArgs.put("metrics-file", "src/main/resources/conf/metrics.xml");
        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
        scheduler.scheduleAtFixedRate(new Runnable() {
            public void run() {
                try {
                    monitor.execute(taskArgs, null);
                } catch (Exception e) {
                    logger.error("Error while running the task", e);
                }
            }
        }, 2, 30, TimeUnit.SECONDS);
    }
 
开发者ID:Appdynamics,项目名称:marklogic-monitoring-extension,代码行数:26,代码来源:MarkLogicMonitor.java

示例2: main

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void main(String[] args) throws TaskExecutionException {

        ConsoleAppender ca = new ConsoleAppender();
        ca.setWriter(new OutputStreamWriter(System.out));
        ca.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
        ca.setThreshold(Level.DEBUG);
        logger.getRootLogger().addAppender(ca);

        final Map<String, String> taskArgs = new HashMap<String, String>();
        taskArgs.put(CONFIG_ARG, "/Users/Muddam/AppDynamics/Code/extensions/kafka-monitoring-extension/src/main/resources/config/config.yml");

        final KafkaMonitor monitor = new KafkaMonitor();
        //monitor.execute(taskArgs, null);

        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
        scheduler.scheduleAtFixedRate(new Runnable() {
            public void run() {
                try {
                    monitor.execute(taskArgs, null);
                } catch (Exception e) {
                    logger.error("Error while running the Task ", e);
                }
            }
        }, 2, 60, TimeUnit.SECONDS);
    }
 
开发者ID:Appdynamics,项目名称:kafka-monitoring-extension,代码行数:26,代码来源:KafkaMonitor.java

示例3: Configuration

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public Configuration() {
    SecureRandom random = new SecureRandom();
    this.log4jLogger = Logger.getLogger("Logger"+ random.nextInt());
    
    //this.log4jLogger.removeAllAppenders();
    ConsoleAppender appender = new ConsoleAppender();
    appender.setWriter(new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8)));
    appender.setLayout(new PatternLayout(PatternLayout.DEFAULT_CONVERSION_PATTERN));
    this.log4jLogger.addAppender(appender);
    
    this.log4jLogger.setLevel(Level.OFF);
}
 
开发者ID:maxamel,项目名称:GDH,代码行数:13,代码来源:Configuration.java

示例4: getConsoleAppender

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Create a console appender that will catch the SoapUI messages.
 *
 * @return with the appender.
 */
public ConsoleAppender getConsoleAppender() {
    ConsoleAppender appender = new ConsoleAppender();
    appender.setWriter(stringWriter);
    appender.setLayout(patternLayout);
    return appender;
}
 
开发者ID:epam,项目名称:Gepard,代码行数:12,代码来源:SoapUITestCase.java


注:本文中的org.apache.log4j.ConsoleAppender.setWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。