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


Java ConsoleAppender.activateOptions方法代码示例

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


在下文中一共展示了ConsoleAppender.activateOptions方法的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: 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

示例4: FileReporterListener

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/** 
*   Constructor; also redirects log4j output to System.out, 
*   which is itself re-directed on a per-test-class basis as described 
*   in class description.
*/
public FileReporterListener()
{       
    setupLogging();
    
    //  configure log4j to write to STDOUT, which we will re-direct on 
    //  a per-test basis
    //
    ConsoleAppender logOutput 
        = new ConsoleAppender( 
            new PatternLayout("%5p: %m (%l)%n"), 
                "System.out" ); 
         
    logOutput.setImmediateFlush( true );
    logOutput.setFollow( true );
    logOutput.activateOptions();
    
    Logger root = Logger.getRootLogger();
    
    root.removeAllAppenders();
    
    root.addAppender( logOutput );        
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:28,代码来源:FileReporterListener.java

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

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

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

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

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

示例10: reconfigLog

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
 *  read log4j properties from user defined location or default location
 * @throws FileNotFoundException 
 */
public void reconfigLog() throws FileNotFoundException {
	File location = _configuration.getLogConfig();
	Level llevel = _configuration.loglevel;
	Logger.getRootLogger().removeAllAppenders();
	progressAndResultLog.setAdditivity(false);
	
	// user provided log location?
	if (location != null) {
		if (!location.exists())
		{
			System.err.printf("User provided log location does not exist: %s", location);
			System.exit(1);
		}
		PropertyConfigurator.configure(new FileInputStream(location));
		log.info("user has provided log level location: " +  location);
	}
	// user has given a global log level
	else if (llevel != null) {
		ConsoleAppender c = new ConsoleAppender();
		c.setLayout(new PatternLayout("%-4r [%t] %-5p %l - %m%n"));
		c.setThreshold(llevel);
		c.activateOptions();
		Logger.getRootLogger().addAppender(c);			
	
		log.info("user set log level to " + llevel.toString());
	}
	// do we have a log file at the default location
	else if (new File(LOG4JPROPERIES_DEFAULT_LOCATION).exists())
	{
		defaultLogPropertyFileConfig();
		log.info("use default log properties location " + LOG4JPROPERIES_DEFAULT_LOCATION);
	}
	// just set everything to error log level
	else {
		defaultLogConfig();
	}
	
	outputLog(llevel == null ? Level.INFO : llevel);	
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:44,代码来源:iBench.java

示例11: outputLog

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public void outputLog(Level l) {
	if (!progressAndResultLog.getAllAppenders().hasMoreElements()) {
		progressAndResultLog.removeAllAppenders();
		ConsoleAppender console = new ConsoleAppender(); 
		String PATTERN = "%m%n";
		console.setLayout(new PatternLayout(PATTERN)); 
		console.setThreshold(l);
		console.activateOptions();
		progressAndResultLog.addAppender(console);
	}
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:12,代码来源:iBench.java

示例12: defaultLogConfig

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public void defaultLogConfig() {
	// standard appender is console
	ConsoleAppender console = new ConsoleAppender(); 
	String PATTERN = "%d [%p] %l %m%n";
	console.setLayout(new PatternLayout(PATTERN)); 
	console.setThreshold(Level.ERROR);
	console.activateOptions();
	Logger.getRootLogger().addAppender(console);
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:10,代码来源:iBench.java

示例13: SetConsoleLogger

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void SetConsoleLogger(Level level) {
    ConsoleAppender ca = new ConsoleAppender();
    ca.setThreshold(level);
    ca.setName("ConsoleLogger_Info");
    ca.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    ca.activateOptions();
    Logger.getRootLogger().getLoggerRepository().resetConfiguration();
    Logger.getRootLogger().addAppender(ca);
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:10,代码来源:ConsoleLogger.java

示例14: CISCoreStandaloneApp

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public CISCoreStandaloneApp() throws CISConfigException {
	ConsoleAppender console = new ConsoleAppender(); //create appender
	  //configure the appender
	  String PATTERN = "%d [%p|%c|%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);

	  FileAppender fa = new FileAppender();
	  fa.setName("CISCoreLogger");
	  fa.setFile("./log/CISCore.log");
	  fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
	  fa.setThreshold(Level.DEBUG);
	  fa.setAppend(true);
	  fa.activateOptions();

	  //add appender to any Logger (here is root)
	  Logger.getRootLogger().addAppender((Appender)fa);
	  //repeat with all other desired appenders
	  
	  log = Logger.getLogger(this.getClass());
	  
	  Boolean ignoreError = Boolean.parseBoolean(PropertiesReader.getInstance().getPropertie("startup.ignore.error"));
	  log.info("Ignore Errors on CoreStartup: " + ignoreError);
	  
	  try {
		  CISCoreImpl cisCore = CISCoreImpl.getInstance();
	  } catch (Exception e) {
		  if (!ignoreError) {
			  throw e;
		  }
	  }
	  
	  ConnectorCallbackHandlerImpl callbackHandler = ConnectorCallbackHandlerImpl.getInstance();
	  callbackHandler.registerCallback(new RestConnectorCallback(PropertiesReader.getInstance().getPropertie("core.connector.rest.callback")));
	  
	  log.info("Init. CISCoreStandaloneApp");
}
 
开发者ID:DRIVER-EU,项目名称:CommonInformationSpace,代码行数:41,代码来源:CISCoreStandaloneApp.java

示例15: main

import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
		UtilFile.defaultBufferSize.set(DemuxedConnection.bufferSize);
		ConsoleAppender console = new ConsoleAppender(); // create appender
		// configure the appender
		String PATTERN = "%d [%p|%c|%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);

		if (args.length > 0) {
			String[] subArgs = new String[args.length - 1];
			System.arraycopy(args, 1, subArgs, 0, subArgs.length);
			if ("server".equals(args[0])) {
				new Server().main(subArgs);
				return;
			} else if ("client".equals(args[0])) {
				new Client().main(subArgs);
				return;
//			} else if ("connect".equals(args[0])) {
//				new Connect().main(subArgs);
//				return;
			} else if ("gui".equals(args[0])) {
				Gui.commandline(subArgs);
				return;
			} else if ("listaudio".equals(args[0])) {
				ListAudio.commandline(subArgs);
				return;
			}
		}
		System.out.println(new HelpTemplate().generate());
	}
 
开发者ID:rizsi,项目名称:rcom,代码行数:34,代码来源:Launcher.java


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