當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。