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


Java ConsoleAppender.setThreshold方法代码示例

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


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

示例1: setUpClass

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
    //Configure log4j
    ConsoleAppender console = new ConsoleAppender(); 
    String PATTERN = "%d [%p|%c|%C{1}] %m%n";
    console.setLayout(new PatternLayout(PATTERN)); 
    console.setThreshold(Level.DEBUG);
    console.activateOptions();

    Logger.getRootLogger().addAppender(console);

    System.out.println("SETUP: Starting SPLGroundControl...");
    config.init(args);

    daemon.init(new SPLGroundControl.SPLDaemonContext(args));
    daemon.start();
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:18,代码来源:SPLGroungControlTest.java

示例2: setupLogging

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
private void setupLogging() {
    LogManager.getLogManager().reset();
    Logger.getRootLogger().getLoggerRepository().resetConfiguration();

    final Logger rootLogger = Logger.getRootLogger();
    final PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n");
    final Level level = endPointHealthConfiguration.logLevel();

    final ConsoleAppender consoleAppender = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_ERR);

    consoleAppender.setThreshold(level);
    consoleAppender.activateOptions();

    final FileAppender fileAppender = new FileAppender();

    fileAppender.setFile(endPointHealthConfiguration.logFile().getAbsolutePath());
    fileAppender.setLayout(layout);
    fileAppender.setThreshold(level);
    fileAppender.setAppend(true);
    fileAppender.setErrorHandler(new FallbackAppenderErrorHandler(rootLogger, fileAppender, consoleAppender));

    rootLogger.addAppender(fileAppender);

    fileAppender.activateOptions();
}
 
开发者ID:spypunk,项目名称:endpoint-health,代码行数:26,代码来源:EndPointHealthServiceImpl.java

示例3: 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

示例4: configureLogging

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Configures the logger.
 */
private static void configureLogging() {
    PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd' 'HH:mm:ss.SSS} [%-5p] [%c] - %m%n");

    ConsoleAppender console = new ConsoleAppender();
    console.setLayout(layout);
    console.setThreshold(Level.INFO);
    console.activateOptions();

    DailyRollingFileAppender file = new DailyRollingFileAppender();
    file.setFile("log/app.log");
    file.setDatePattern("'.'yyyy-MM-dd");
    file.setLayout(layout);
    file.activateOptions();

    org.apache.log4j.Logger logger = org.apache.log4j.Logger.getRootLogger();
    logger.addAppender(console);
    logger.addAppender(file);
}
 
开发者ID:jpdillingham,项目名称:SeedboxSync,代码行数:22,代码来源:SeedboxSync.java

示例5: 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

示例6: setupLoggers

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
protected static void setupLoggers(Level benchmarkLevel, Level algoLevel, Level consoleLevel) {
    LoggerHelper.DEFAULT_CONSOLE_LAYOUT = new PatternLayout(
            "%d{dd|HH:mm:ss} %-5p %-15c [%-10t] : %m%n");
    //
    // LoggerHelper.setupRootLogger(benchmarkLevel, benchmarkLevel, true);
    //
    // HeuristicsLogging.getRunLogger().setLevel(algoLevel);
    // AdaptiveLargeNeighborhoodSearch.getLogger().setLevel(algoLevel);
    // TRSPLogging.getRunLogger().setLevel(algoLevel);
    Logger.getRootLogger().setLevel(LoggerHelper.LEVEL_WARN);

    ConsoleAppender appender = new ConsoleAppender(LoggerHelper.DEFAULT_CONSOLE_LAYOUT);
    appender.setThreshold(consoleLevel != null ? consoleLevel : benchmarkLevel);
    TRSPLogging.getRunLogger().addAppender(appender);
    Logging.getSetupLogger().addAppender(appender);

    Logging.getSetupLogger().setLevel(LoggerHelper.LEVEL_WARN);
    TRSPLogging.getRunLogger().setLevel(benchmarkLevel);
    TRSPLogging.getSimulationLogger().setLevel(benchmarkLevel);

    if (sVerbose) {
        System.out.println("Enabled verbose logging");
        DTRSPRunMPA.setupVerboseLoggers();
    }
}
 
开发者ID:vpillac,项目名称:vroom,代码行数:26,代码来源:TRSPBench.java

示例7: setupLogging

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Setup log4j logging
 * 
 * @param logFile  log file
 * @param debug true if debug messages should be logged (use -Ddebug=true to enable debug message)
 */
public static void setupLogging(File logFile, boolean debug) {
    Logger root = Logger.getRootLogger();
    ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
    console.setThreshold(Level.INFO);
    root.addAppender(console);
    if (logFile != null) {
        try {
            FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
            file.setThreshold(Level.DEBUG);
            root.addAppender(file);
        } catch (IOException e) {
            sLogger.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
        }
    }
    if (!debug)
        root.setLevel(Level.INFO);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:Test.java

示例8: prepareExperimentLog

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
protected void prepareExperimentLog() throws IOException {
	final ConsoleAppender console = new ConsoleAppender(); // create
															// appender
	// configure the appender
	final String PATTERN = "[%p->%C{1}] %m%n";
	console.setLayout(new PatternLayout(PATTERN));
	console.setThreshold(Level.INFO);
	console.activateOptions();
	// add appender to any Logger (here is root)
	Logger.getRootLogger().addAppender(console);
	final File expRoot = prepareExperimentRoot();

	final File logFile = new File(expRoot, "log");
	if (logFile.exists())
		logFile.delete();
	final String TIMED_PATTERN = "[%d{HH:mm:ss} %p->%C{1}] %m%n";
	final FileAppender file = new FileAppender(new PatternLayout(TIMED_PATTERN), logFile.getAbsolutePath());
	file.setThreshold(Level.DEBUG);
	file.activateOptions();
	Logger.getRootLogger().addAppender(file);
	logger.info("Experiment root: " + expRoot);

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:LambdaSearchAustrian.java

示例9: setupLogging

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Setup log4j logging
 * 
 * @param logFile  log file
 */
public static void setupLogging(File logFile) {
    Logger root = Logger.getRootLogger();
    ConsoleAppender console = new ConsoleAppender(new PatternLayout("[%t] %m%n"));
    console.setThreshold(Level.INFO);
    root.addAppender(console);
    if (logFile != null) {
        try {
            FileAppender file = new FileAppender(new PatternLayout("%d{dd-MMM-yy HH:mm:ss.SSS} [%t] %-5p %c{2}> %m%n"), logFile.getPath(), false);
            file.setThreshold(Level.DEBUG);
            root.addAppender(file);
        } catch (IOException e) {
            sLog.fatal("Unable to configure logging, reason: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:21,代码来源:Test.java

示例10: prepareExperimentLog

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
protected void prepareExperimentLog(BilinearLearnerParameters params) throws IOException {
	ConsoleAppender console = new ConsoleAppender(); //create appender
	//configure the appender
	String PATTERN = "[%p->%C{1}] %m%n";
	console.setLayout(new PatternLayout(PATTERN)); 
	console.setThreshold(Level.DEBUG);
	console.activateOptions();
  	// add appender to any Logger (here is root)
	Logger.getRootLogger().addAppender(console);
	File expRoot = prepareExperimentRoot();
	
	IOUtils.write(params, new DataOutputStream(new FileOutputStream(new File(expRoot,PARAMS_DATA_NAME))));
	IOUtils.writeASCII(new File(expRoot,PARAMS_NAME), params);
	
	File logFile = new File(expRoot,"log");
	if(logFile.exists())logFile.delete();
	FileAppender file = new FileAppender(new PatternLayout(PATTERN), logFile.getAbsolutePath()); 
	file.setThreshold(Level.DEBUG);
	file.activateOptions();
	Logger.getRootLogger().addAppender(file );
	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:BilinearExperiment.java

示例11: errorOnlyConsole

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void errorOnlyConsole() {
  LogManager.resetConfiguration();

  final PatternLayout layout = new PatternLayout();
  layout.setConversionPattern("%-5p %c %x: %m%n");

  final ConsoleAppender dst = new ConsoleAppender();
  dst.setLayout(layout);
  dst.setTarget("System.err");
  dst.setThreshold(Level.ERROR);
  dst.activateOptions();

  final Logger root = LogManager.getRootLogger();
  root.removeAllAppenders();
  root.addAppender(dst);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ErrorLogFile.java

示例12: main

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	System.setProperty("log4j.defaultInitOverride", "true");
	LogManager.resetConfiguration();
	ConsoleAppender ca = new ConsoleAppender(new PatternLayout("%-5p - %m%n"));
	ca.setName("edits");
	LogManager.getRootLogger().addAppender(ca);
	Options ops = new Options();
	ops.addOption("optimize", false, "");
	ops.addOption("balance", false, "");
	ops.addOption("rules", false, "");
	ops.addOption("debug", false, "");
	ops.addOption("wordnet", true, "");

	CommandLine commandLine = new BasicParser().parse(ops, args);

	if (!commandLine.hasOption("debug"))
		ca.setThreshold(Level.INFO);

	RunExperiment res = new RunExperiment(commandLine.getArgs()[0], commandLine.hasOption("balance"),
			commandLine.hasOption("optimize"), commandLine.hasOption("rules"));

	if (commandLine.hasOption("wordnet"))
		res.setRulesSource(new WordnetRulesSource(commandLine.getOptionValue("wordnet")));

	res.train(commandLine.getArgs()[1]);
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:27,代码来源:RunExperiment.java

示例13: setLogLevel

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
private void setLogLevel(String level) {
    Level newLevel = Level.ERROR;
    level = level.substring(level.lastIndexOf(' ') + 1);
    switch (level) {
        case "Debug":
            newLevel = Level.DEBUG;
            break;
        case "Info":
            newLevel = Level.INFO;
            break;
        case "Warn":
            newLevel = Level.WARN;
            break;
        case "Error":
            newLevel = Level.ERROR;
            break;
    }
    Logger.getRootLogger().setLevel(newLevel);
    logger.setLevel(newLevel);
    ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout");
    if (ca != null) {
        ca.setThreshold(newLevel);
    }
    FileAppender fa = (FileAppender)Logger.getRootLogger().getAppender("FILE");
    if (fa != null) {
        fa.setThreshold(newLevel);
    }
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:29,代码来源:MainWindow.java

示例14: getLogger

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Singleton pattern for logger
 * Adds a <code>ConsoleAppender</code> on initialization
 * @return <code>Logger</code>
 */
public static Logger getLogger() {
    if(logger == null) {
        logger = Logger.getRootLogger();
        ConsoleAppender appender = new ConsoleAppender();

        appender.setLayout(new PatternLayout("[%-5p] %d{HH:mm:ss.SSS} [%t] - %m %n"));
        appender.setThreshold(Level.ALL);
        appender.activateOptions();
        logger.addAppender(appender);
    }
    return logger;
}
 
开发者ID:NoahLutz,项目名称:gmusic-java,代码行数:18,代码来源:Utils.java

示例15: setUp

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public void setUp() {
  	System.setProperty( "javax.net.ssl.keyStore",  TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.trustStore", TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.keyStorePassword", "passphrase" );
System.setProperty( "javax.net.ssl.keyStoreType", "jks" );
  	ConsoleAppender console = new ConsoleAppender();
  	console.setName("Console app");
  	String PATTERN = "%d [%p|%c|%C{1}] %m%n";
  	console.setLayout(new PatternLayout(PATTERN)); 
  	console.setThreshold(Level.DEBUG);
  	console.activateOptions();
  	Logger.getRootLogger().addAppender(console);
  	this.websocketServer = new WebsocketServer();
  	this.websocketBrowser = new WebsocketBrowser();
  }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:16,代码来源:WebsocketSelfTest.java


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