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


Java BasicConfigurator.configure方法代碼示例

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


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

示例1: getWriter

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
 * Get singleton instance of RdfWriter
 *
 * @return instance of RdfWriter
 */
public static RdfWriter getWriter() {
    if (writer == null) {
        BasicConfigurator.configure();
        writer = new RdfWriter();
    }
    writer.model = ModelFactory.createDefaultModel();
    writer.list = new LinkedBlockingQueue<>();
    return writer;
}
 
開發者ID:infovillasimius,項目名稱:amr2Fred,代碼行數:15,代碼來源:RdfWriter.java

示例2: before

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Override
public void before() throws Throwable {
    if (notConfigured) {
        //Now configure Log4J with console appender
        BasicConfigurator.configure();
        System.out.println("Configure Log4J for basic output...");
        System.out.println("Set root LOGGER loglevel to '" + rootLevel.toString() + "'!");
        Logger.getRootLogger().setLevel(rootLevel);
    }
    if (logger == null) {
        Logger.getRootLogger().setAdditivity(false);
        logger = Logger.getLogger(InitLog4jLoggingRule.class);
        logger.setAdditivity(false);
    }
    //Init FirstSpirit Logging with special logger
    Logging.init(new FS2Log4JLogger());
}
 
開發者ID:e-Spirit,項目名稱:FSTestTools,代碼行數:18,代碼來源:InitLog4jLoggingRule.java

示例3: main

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) throws ParseException {
  Options options = new Options();
  Option nameOption = new Option("n", true, "Name to resolve");
  nameOption.setRequired(true);
  options.addOption(nameOption);
  CommandLineParser parser = new BasicParser();
  CommandLine cmd = parser.parse(options, args);

  BasicConfigurator.configure();
  Logger.getRootLogger().setLevel(Level.DEBUG);
  PodCIDRToNodeMapping plugin = new PodCIDRToNodeMapping();
  Configuration conf = new Configuration();
  plugin.setConf(conf);

  String nameToResolve = cmd.getOptionValue(nameOption.getOpt());
  List<String> networkPathDirs = plugin.resolve(Lists.newArrayList(nameToResolve));
  log.info("Resolved " + nameToResolve + " to " + networkPathDirs);
}
 
開發者ID:apache-spark-on-k8s,項目名稱:kubernetes-HDFS,代碼行數:19,代碼來源:PodCIDRToNodeMapping.java

示例4: clockSkewFailure_CorrectsGlobalTimeOffset

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
 * In the following test, we purposely setting the time offset to trigger a clock skew error.
 * The time offset must be fixed and then we validate the global value for time offset has been
 * update.
 */
@Test
public void clockSkewFailure_CorrectsGlobalTimeOffset() throws Exception {
    BasicConfigurator.configure();
    final int originalOffset = SdkGlobalTime.getGlobalTimeOffset();
    final int skew = 3600;

    SdkGlobalTime.setGlobalTimeOffset(skew);
    assertEquals(skew, SdkGlobalTime.getGlobalTimeOffset());
    SQSAsyncClient sqsClient = createSqsAyncClient();

    sqsClient.listQueues(ListQueuesRequest.builder().build()).thenCompose( __ -> {
        assertThat("Clockskew is fixed!", SdkGlobalTime.getGlobalTimeOffset(), lessThan(skew));
        // subsequent changes to the global time offset won't affect existing client
        SdkGlobalTime.setGlobalTimeOffset(skew);
        return sqsClient.listQueues(ListQueuesRequest.builder().build());
    }).thenAccept( __ ->  {
        assertEquals(skew, SdkGlobalTime.getGlobalTimeOffset());
    }).join();

    sqsClient.close();

    SdkGlobalTime.setGlobalTimeOffset(originalOffset);
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:29,代碼來源:SqsIntegrationTest.java

示例5: main

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) {
	try {
		BasicConfigurator.configure();
		Debug.info(" - Initializing Hibernate ... ");
		_RootDAO.initialize();

		ApplicationProperties.getConfigProperties().setProperty(
				ApplicationProperty.CustomizationDefaultCourseUrl.key(),
				"http://syllabuskrk.agh.edu.pl/:years/pl/magnesite/modules/:courseNbr");
		ApplicationProperties.getConfigProperties().setProperty("unitime.custom.default.course_api_url",
				"http://syllabuskrk.agh.edu.pl/api/:years/modules/:courseNbr");
		
		
		ApplicationProperties.getDefaultProperties()
				.setProperty(ApplicationProperty.CustomizationDefaultCourseDetailsDownload.key(), "true");

		System.out.println("URL:" + new AGHCourseDetailsProvider()
				.getCourseUrl(new AcademicSessionInfo(231379l, "2015", "Semestr zimowy", "AGH"), "BAND", "101"));

		System.out.println("Details:\n" + new AGHCourseDetailsProvider()
				.getDetails(new AcademicSessionInfo(231379l, "2015", "Semestr zimowy", "AGH"), "BAND", "101"));

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:27,代碼來源:AGHCourseDetailsProvider.java

示例6: main

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
 * main.
 * @param args {@link String}{@code []}
 * @throws IOException due to file errors.
 */
@SuppressWarnings("nls")
public static void main(final String[] args) throws IOException {

    BasicConfigurator.configure();

    final File in = new File("src/test/mp3/1000Hz.mp3");
    // assume there is just one id 3 tag at the very beginning...
    final ID3Tag firstID3Tag = MPEGAudio.decodeFirstID3Tag(in);
    if (LOG.isInfoEnabled()) {
        LOG.info("" + firstID3Tag); //$NON-NLS-1$
    }
    final DecodingResult dr = MPEGAudio.decode(in, MPEGAudioContentFilter.MPEG_AUDIO_FRAMES);
    //        final File out = File.createTempFile("TestIntegrationReadWrite-TEST", ".mp3"); //$NON-NLS-1$ //$NON-NLS-2$
    final File out = new File("out.mp3");
    if (LOG.isInfoEnabled()) {
        LOG.info("Created tmp file [" + out.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
    }
    try (FileOutputStream fos = new FileOutputStream(out)) {
        final WaveFormGainFilter filter = new CosineGainFilter();
        filter.setWavelengthInSecs(20f);
        //            Filter filter = new FixFactorGainFIlter(0.9);
        MPEGAudio.encode(dr.getContent(), filter, fos, true);
    }

}
 
開發者ID:addradio,項目名稱:mpeg-audio-streams,代碼行數:31,代碼來源:AppTestApplyGainFilter.java

示例7: main

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) {

        BasicConfigurator.configure();

        port(4567);
        if (getPassword() != null && getKeystorePath() != null) {
            secure(getKeystorePath(), getPassword(), null, null);
        }

        staticFiles.location("/public");
        staticFiles.expireTime(600L);

        before("*", Filters.addTrailingSlashes);
        before("*", Filters.handleLocaleChange);

        get(Path.Web.INDEX, IndexController.serveIndexPage);
        get(Path.Web.PARSE, DatalogController.parseDatalog);

        after("*", Filters.addGzipHeader);
    }
 
開發者ID:Joklost,項目名稱:datalog-parser,代碼行數:21,代碼來源:Application.java

示例8: testLog4JAppendString

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testLog4JAppendString() throws Exception {
	BasicConfigurator.configure();
	org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("com.db.fxpricing.Logger");

	for(long i = 0; i < WARMUP_COUNT; i++)
		log.info("value");
	Thread.sleep(1000L);

	objectCounting.set(true);
	for(long i = 0; i < TEST_COUNT; i++)
		log.info("value");

	Thread.sleep(500L);

	printState("log4j-string");
}
 
開發者ID:vladimirdolzhenko,項目名稱:gflogger,代碼行數:18,代碼來源:TestGarbageDefaultLoggerServiceImpl.java

示例9: init

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
 * Initialization of the servlet. <br>
 *
 * @throws ServletException if an error occurs
 */
public void init(ServletConfig config) throws ServletException {
	// Put your code here
	System.out.println("Log4jServlet 正在初始化log4j日誌設置信息");
	String log4jLocation = config.getInitParameter("log4j-properties-location");
	ServletContext sc = config.getServletContext();
	if(log4jLocation == null){
		System.out.println("** 沒有log4j-properties-location 初始化文件,所以使用BasicConfiguratorc初始化 **");
		BasicConfigurator.configure();
	}else{
		String webAppPath = sc.getRealPath("/");
		String log4jProp = webAppPath + log4jLocation;
		File log4File = new File(log4jProp);
		if(log4File.exists()){
			System.out.println("使用:"+ log4jProp + "初始化日誌設置信息");
			PropertyConfigurator.configure(log4jProp);
		}else{
			System.out.println("*****" + log4jProp + "文件沒有找到,所以使用BasicConfigurator初始化*****");
			BasicConfigurator.configure();
		}
	}
	super.init(config);
	System.out.println("---------log4jServlet  初始化log4j日誌設置信息完成--------");
		
}
 
開發者ID:wqxcloud,項目名稱:Android-Client-Server,代碼行數:30,代碼來源:Log4jServlet.java

示例10: testLog4JAppendLongs

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testLog4JAppendLongs() throws Exception {
	BasicConfigurator.configure();
	org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("com.db.fxpricing.Logger");

	for(long i = 0; i < WARMUP_COUNT; i++)
		log.info("value:" + i + " " + i + " " + i + " " + i + " " + i
				+ i + " " + i + " " + i + " " + i + " " + i);
	Thread.sleep(1000L);

	objectCounting.set(true);
	for(long i = 0; i < TEST_COUNT; i++)
		log.info("value:" + i + " " + i + " " + i + " " + i + " " + i
				+ i + " " + i + " " + i + " " + i + " " + i);

	Thread.sleep(500L);

	printState("log4j-longs");
}
 
開發者ID:vladimirdolzhenko,項目名稱:gflogger,代碼行數:20,代碼來源:TestGarbageDefaultLoggerServiceImpl.java

示例11: testBson

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testBson () throws IOException
{
	BasicConfigurator.configure ();
	String f = "../tests/data/data1.bson";
	File file = new File (f.replace ('/', File.separatorChar));

	JsonPathProvider provider = new JsonPathProvider ();

	Configuration pathConfig = Configuration.defaultConfiguration ().jsonProvider (provider);
	JsonPath path = JsonPath.compile ("$..A");

	JsonProvider p = new CookJsonProvider ();
	HashMap<String, Object> readConfig = new HashMap<String, Object> ();
	readConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	readConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);
	JsonReaderFactory rf = p.createReaderFactory (readConfig);
	JsonReader reader = rf.createReader (new FileInputStream (file));
	JsonStructure obj = reader.read ();
	reader.close ();

	JsonValue value = path.read (obj, pathConfig);

	Assert.assertEquals ("[1,3,5,7]", provider.toJson (value));
}
 
開發者ID:coconut2015,項目名稱:cookjson,代碼行數:26,代碼來源:JsonPathProviderTest.java

示例12: before

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Before
public void before() throws Exception {
    BasicConfigurator.configure();
    Scheduler.$.initLogging();

    File storageFile = Files.createTempFile(MesosTestCase.class.getSimpleName(), null).toFile();
    assertTrue(storageFile.delete());
    Nodes.storage = Storage.file(storageFile);
    Nodes.reset();

    Scheduler.Config config = Scheduler.$.config;
    config.api = "http://localhost:" + Net.findAvailPort();
    config.jar = new File("hdfs-mesos-0.1.jar");
    config.hadoop = new File("hadoop-1.2.1.tar.gz");

    Cli.api = config.api;
    Scheduler.$.subscribed(schedulerDriver, "id", new Master());
}
 
開發者ID:elodina,項目名稱:hdfs-mesos,代碼行數:19,代碼來源:HdfsMesosTestCase.java

示例13: main

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
    // Configure console logging
    BasicConfigurator.configure();

    String topic = "publishing_to_topic";
    if (args.length > 0) {
        topic = args[0];
    }
    System.out.println("Publishing to topic " + topic);

    while (!Thread.currentThread().isInterrupted()) {
        String s = RandomStringUtils.randomAlphanumeric(10);
        PubSub.publish(topic, s);
        Thread.sleep(1000);
    }
}
 
開發者ID:brownsys,項目名稱:tracing-framework,代碼行數:17,代碼來源:PublishTool.java

示例14: init

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
 * @param defaultLogSettingsPath
 *            Path to the default log settings
 * @param logsDirectory
 *            Path to the directory where the log files are stored
 */
public static void init(String defaultLogSettingsPath, String logsDirectory) {
    Properties settings = new Properties();
    try (InputStream is = FileUtils.getResourceInputStream(defaultLogSettingsPath)) {
        settings.load(is);
    } catch (IOException e) {
        Log.log.error("Could not load default log settings: " + e.getMessage());
    }

    String filePattern = "'jhv.'yyyy-MM-dd'T'HH-mm-ss'.log'";

    settings.setProperty("log4j.appender.file.Directory", logsDirectory);
    settings.setProperty("log4j.appender.file.Pattern", filePattern);

    SimpleDateFormat formatter = new SimpleDateFormat(filePattern);
    formatter.setTimeZone(TimeZone.getTimeZone(System.getProperty("user.timezone")));
    settings.setProperty("log4j.appender.file.TimeStamp", formatter.format(new Date()));

    BasicConfigurator.configure();
    PropertyConfigurator.configure(settings);
}
 
開發者ID:Helioviewer-Project,項目名稱:JHelioviewer-SWHV,代碼行數:27,代碼來源:LogSettings.java

示例15: setUp

import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();
    
    servlet = new MainServlet();
    
    ctx = mock(ConfigContext.class);
    ConfigContext.overwriteCurrentInstance(ctx);
    
    session = mock(HttpSession.class);
    
    request = mock(HttpServletRequest.class);
    when(request.getSession(true)).thenReturn(session);
    when(request.getRequestURL()).thenReturn(new StringBuffer("http://test.localhost:1234/annotator/home"));
    
    outputBuf = new StringWriter();
    PrintWriter output = new PrintWriter(outputBuf);
    
    response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(output);
}
 
開發者ID:memphis-iis,項目名稱:gluten,代碼行數:22,代碼來源:MainServletTest.java


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