org.apache.log4j.BasicConfigurator Java Examples

The following examples show how to use org.apache.log4j.BasicConfigurator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EchoNetTest.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testProcess() {
    BasicConfigurator.configure();
    
    // DicomNode calling = new DicomNode("WEA-SCU");
    // DicomNode called = new DicomNode("DCM4CHEE", "localhost", 11112);
    // AdvancedParams params = new AdvancedParams();
    // TlsOptions tls =
    // new TlsOptions(true, "/home/dcm4chee/dcm4chee-2.18.0-mysql/server/default/conf/keystore.jks", "JKS",
    // "keypwd", "keypwd", "/home/dcm4chee/dcm4chee-2.18.0-mysql/server/default/conf/trust.jks", "JKS",
    // "trustpwd");
    // params.setTlsOptions(tls);
    // DicomState state = Echo.process(params, calling, called);

    DicomNode calling = new DicomNode("WEASIS-SCU");
    DicomNode called = new DicomNode("DICOMSERVER", "dicomserver.co.uk", 11112);
    DicomState state = Echo.process(null, calling, called);
    // Should never happen
    Assert.assertNotNull(state);

    System.out.println("DICOM Status:" + state.getStatus());
    System.out.println(state.getMessage());
    // see org.dcm4che3.net.Status
    // See server log at http://dicomserver.co.uk/logs/
    Assert.assertThat(state.getMessage(), state.getStatus(), IsEqual.equalTo(Status.Success));
}
 
Example #2
Source File: PublishTool.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: Log4jInit.java    From CRF with MIT License 6 votes vote down vote up
public static void init(Level level)
{
	if (!alreadyInitialized)
	{
		synchronized(Log4jInit.class)
		{
			if (!alreadyInitialized)
			{
				final Layout layout = new VerySimpleLayout(); // new PatternLayout("%p [%t] %m%n");
				BasicConfigurator.configure();
				Logger.getRootLogger().setLevel(level);
				
				Enumeration<?> enumAppenders = Logger.getRootLogger().getAllAppenders();
				while (enumAppenders.hasMoreElements())
				{
					Appender appender = (Appender) enumAppenders.nextElement();
					appender.setLayout(layout);
				}
				
				alreadyInitialized = true;
			}
		}
	}

}
 
Example #4
Source File: HelloWorldHystrixObservableCommand.java    From learning-code with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    BasicConfigurator.configure();
    HelloWorldHystrixObservableCommand command = new HelloWorldHystrixObservableCommand("kronchan");
    Observable<String> observable = command.observe();
    observable.subscribe(new Observer<String>() {
        @Override
        public void onCompleted() {
            log.info("completed");
        }

        @Override
        public void onError(Throwable throwable) {
            log.error(throwable.getMessage());
        }

        @Override
        public void onNext(String o) {
            log.info("Observe onNext: {}", o);
        }
    });
}
 
Example #5
Source File: SimpleEVCacheTest.java    From EVCache with Apache License 2.0 6 votes vote down vote up
@BeforeSuite
public void setProps() {
    BasicConfigurator.resetConfiguration();
    BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%d{HH:mm:ss,SSS} [%t] %p %c %x - %m%n")));
    Logger.getRootLogger().setLevel(Level.INFO);
    Logger.getLogger(SimpleEVCacheTest.class).setLevel(Level.DEBUG);
    Logger.getLogger(Base.class).setLevel(Level.DEBUG);
    Logger.getLogger(EVCacheImpl.class).setLevel(Level.DEBUG);
    Logger.getLogger(EVCacheClient.class).setLevel(Level.DEBUG);
    Logger.getLogger(EVCacheClientPool.class).setLevel(Level.DEBUG);

    final Properties props = getProps();
    props.setProperty("EVCACHE_TEST.use.simple.node.list.provider", "true");
    props.setProperty("EVCACHE_TEST.EVCacheClientPool.readTimeout", "1000");
    props.setProperty("EVCACHE_TEST.EVCacheClientPool.bulkReadTimeout", "1000");
    props.setProperty("EVCACHE_TEST.max.read.queue.length", "100");
    props.setProperty("EVCACHE_TEST.operation.timeout", "10000");
    props.setProperty("EVCACHE_TEST.throw.exception", "false");

    int maxThreads = 2;
    final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(100000);
    pool = new ThreadPoolExecutor(maxThreads * 4, maxThreads * 4, 30, TimeUnit.SECONDS, queue);
    pool.prestartAllCoreThreads();
}
 
Example #6
Source File: MergeTool.java    From rya with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final String log4jConfiguration = System.getProperties().getProperty("log4j.configuration");
    if (StringUtils.isNotBlank(log4jConfiguration)) {
        final String parsedConfiguration = PathUtils.clean(StringUtils.removeStart(log4jConfiguration, "file:"));
        final File configFile = new File(parsedConfiguration);
        if (configFile.exists()) {
            DOMConfigurator.configure(parsedConfiguration);
        } else {
            BasicConfigurator.configure();
        }
    }
    log.info("Starting Merge Tool");

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(final Thread thread, final Throwable throwable) {
            log.error("Uncaught exception in " + thread.getName(), throwable);
        }
    });

    final int returnCode = setupAndRun(args);

    log.info("Finished running Merge Tool");

    System.exit(returnCode);
}
 
Example #7
Source File: TestAllMethodsDirtyER.java    From JedAIToolkit with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    BasicConfigurator.configure();

    String mainDir = "D:\\Data\\JedAIdata\\datasets\\dirtyErDatasets\\";
    final String[] datasets = {"census", "cddb", "cora"};

    for (String dataset : datasets) {
        System.out.println("\n\n\n\n\nCurrent dataset\t:\t" + dataset);
        final EntitySerializationReader inReaderD1 = new EntitySerializationReader(mainDir + dataset + "Profiles");
        final List<EntityProfile> profiles = inReaderD1.getEntityProfiles();
        System.out.println("Profiles D1\t:\t" + profiles.size());

        final AttributeValueClustering avc = new AttributeValueClustering(RepresentationModel.CHARACTER_TRIGRAMS, SimilarityMetric.ENHANCED_JACCARD_SIMILARITY);
        final AttributeClusters[] clusters = avc.getClusters(profiles);
        for (int j = 0; j < clusters.length; j++) {
            System.out.println("\nDataset\t:\t" + (j + 1));
            for (int k = 0; k < clusters[j].getNoOfClusters(); k++) {
                System.out.println(k + "\t" + clusters[j].getClusterEntropy(k));
            }
        }
    }
}
 
Example #8
Source File: Log4JInitServlet.java    From olat with Apache License 2.0 6 votes vote down vote up
@Override
public void init() {
    String file = getInitParameter("log4j-init-file");
    ClassPathResource res = new ClassPathResource(file);
    if (!res.exists()) {
        // creating basic log4j configuration which writes to console out, Only called when not yet configured
        ConsoleAppender appender = new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %5p %c{1}:%L - %m%n"), ConsoleAppender.SYSTEM_OUT);
        appender.setThreshold(Level.INFO);
        BasicConfigurator.configure(appender);

        log.info("*****************************************************************************************");
        log.info("You don't provide a log4j config file for your OLAT instance. OLAT will just log to standard out (e.g. catalina.out)."
                + " Please provide a proper log config file (log4j.xml, see olat/conf for an example or read the installation guide) "
                + "and place it into the root of the classpath e.g. tomcat/lib or WEB-INF/classes");
        log.info("*****************************************************************************************");
    }
}
 
Example #9
Source File: TestGarbageDefaultLoggerServiceImpl.java    From gflogger with Apache License 2.0 6 votes vote down vote up
@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");
}
 
Example #10
Source File: Log4JInitServlet.java    From olat with Apache License 2.0 6 votes vote down vote up
@Override
public void init() {
    String file = getInitParameter("log4j-init-file");
    ClassPathResource res = new ClassPathResource(file);
    if (!res.exists()) {
        // creating basic log4j configuration which writes to console out, Only called when not yet configured
        ConsoleAppender appender = new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %5p %c{1}:%L - %m%n"), ConsoleAppender.SYSTEM_OUT);
        appender.setThreshold(Level.INFO);
        BasicConfigurator.configure(appender);

        log.info("*****************************************************************************************");
        log.info("You don't provide a log4j config file for your OLAT instance. OLAT will just log to standard out (e.g. catalina.out)."
                + " Please provide a proper log config file (log4j.xml, see olat/conf for an example or read the installation guide) "
                + "and place it into the root of the classpath e.g. tomcat/lib or WEB-INF/classes");
        log.info("*****************************************************************************************");
    }
}
 
Example #11
Source File: ControlPanelDebug.java    From ChatGameFontificator with The Unlicense 6 votes vote down vote up
/**
 * Enable or disable debugging
 * 
 * @param debugging
 */
public void setDebugging(boolean debugging)
{
    this.debugging = debugging;
    if (debugging)
    {
        Thread.setDefaultUncaughtExceptionHandler(debugAppender);
        BasicConfigurator.configure(debugAppender);
    }
    else
    {
        // Turn off everything before disabling the debug tab
        postClock.stop();
        postMessagesButton.setSelected(false);
        drawTextGridBox.setSelected(false);
        drawBorderGridBox.setSelected(false);
        chat.repaint();
        Thread.setDefaultUncaughtExceptionHandler(null);
        Logger.getRootLogger().removeAppender(debugAppender);
    }
}
 
Example #12
Source File: RdfSClassGenerator.java    From semweb4j with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void generateCode() throws MojoExecutionException, MojoFailureException {
	try {
	    // make sure that directory for log file exists.
	    rdfReactorLogfile.getParentFile().mkdirs();
		
	    // configure logging infrastructure for RDFReactor
	    FileAppender logFileAppender = new FileAppender(new SimpleLayout(), rdfReactorLogfile.getAbsolutePath());
		BasicConfigurator.configure(logFileAppender);

	} catch (IOException ioe) {
		throw new MojoExecutionException("Cannot open log file for writing RDFReactor log messages", ioe);
	}

	getLog().info("Generating code from RDF schema file " + schemaFile + " into dir " + outputDirectory
			+ ". Classes will be in package " + packageName + " and with method prefix " + methodPrefix +". skipBuiltins is " + skipBuiltins + ".");
	getLog().info("RDFReactor's log messages are written to " + rdfReactorLogfile);


	try {
		CodeGenerator.generate(schemaFile.getAbsolutePath(), outputDirectory.getAbsolutePath(), packageName, Reasoning.rdfs, skipBuiltins, methodPrefix);
	} catch (Exception e) {
		e.printStackTrace();
	    throw new MojoFailureException(e, "RDFS processing error", "Could not generate code from the specified RDF schema file.");
	}
}
 
Example #13
Source File: AssignmentActionTestTools.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Before
public void setUp() {
    BasicConfigurator.configure();
    PowerMockito.mockStatic(ComponentManager.class);
    // A mock component manager.
    when(ComponentManager.get(any(Class.class))).then(new Answer<Object>() {
        private Map<Class, Object> mocks = new HashMap<>();
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Class classToMock = (Class) invocation.getArguments()[0];
            return mocks.computeIfAbsent(classToMock, k -> mock(classToMock));
        }
    });
    
    when(ComponentManager.get(SessionManager.class).getCurrentSession()).thenReturn(mock(Session.class));
    when(formattedText.getDecimalSeparator()).thenReturn(".");
    
    when(formattedText.getNumberFormat()).thenReturn(NumberFormat.getInstance(Locale.ENGLISH));
    assignmentAction = new AssignmentAction();

    Mockito.when(ComponentManager.get(AssignmentService.class)).thenReturn(assignmentService);

}
 
Example #14
Source File: NTEventLogAppenderTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 *   Simple test of NTEventLogAppender.
 */
public void testSimple() {
  BasicConfigurator.configure(new NTEventLogAppender());
  Logger logger = Logger.getLogger("org.apache.log4j.nt.NTEventLogAppenderTest");
  int i  = 0;
  logger.debug( "Message " + i++);
  logger.info( "Message " + i++);
  logger.warn( "Message " + i++);
  logger.error( "Message " + i++);
  logger.log(Level.FATAL, "Message " + i++);
  logger.debug("Message " + i++,  new Exception("Just testing."));
}
 
Example #15
Source File: TestBlast.java    From JedAIToolkit with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
        BasicConfigurator.configure();

        String fileName = "/home/gap2/data/JedAIdata/blocks/dblpAcm/sb";
        float bpRatio = 0.004f;
        float bfRatio = 0.5000000000000003f;

        final EntitySerializationReader inReader = new EntitySerializationReader(null);
        final List<AbstractBlock> blocks = (List<AbstractBlock>) inReader.loadSerializedObject(fileName);

        final SizeBasedBlockPurging sbbp = new SizeBasedBlockPurging(bpRatio);
        final List<AbstractBlock> purgedBlocks = sbbp.refineBlocks(blocks);

        final BlockFiltering bf = new BlockFiltering(bfRatio);
        final List<AbstractBlock> filteredBlocks = bf.refineBlocks(purgedBlocks);

        final IGroundTruthReader gtReader = new GtSerializationReader("/home/gap2/data/JedAIdata/datasets/cleanCleanErDatasets/dblpAcmIdDuplicates");
        final Set<IdDuplicates> duplicatePairs = gtReader.getDuplicatePairs(null);
        final AbstractDuplicatePropagation adp = new BilateralDuplicatePropagation(duplicatePairs);

        BlocksPerformance blockStats = new BlocksPerformance(filteredBlocks, adp);
        blockStats.setStatistics();
        blockStats.printStatistics(0, "", "");
        final float originalPC = blockStats.getPc();
        System.out.println("Original PC\t:\t" + originalPC);

//        final BLAST blast = new BLAST();
        final WeightedNodePruning blast = new WeightedNodePruning();
        final List<AbstractBlock> newBlocks = blast.refineBlocks(filteredBlocks);
        blockStats = new BlocksPerformance(newBlocks, adp);
        blockStats.setStatistics();
        blockStats.printStatistics(0, "", "");
        final float newPC = blockStats.getPc();
        System.out.println("New PC\t:\t" + newPC);
    }
 
Example #16
Source File: AbstractFTGSMergerCase.java    From imhotep with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void initLog4j() {
    BasicConfigurator.resetConfiguration();
    BasicConfigurator.configure();

    final Layout LAYOUT = new PatternLayout("[ %d{ISO8601} %-5p ] [%c{1}] %m%n");

    LevelRangeFilter ERROR_FILTER = new LevelRangeFilter();
    ERROR_FILTER.setLevelMin(Level.ERROR);
    ERROR_FILTER.setLevelMax(Level.FATAL);

    // everything including ERROR
    final Appender STDOUT = new ConsoleAppender(LAYOUT, ConsoleAppender.SYSTEM_OUT);

    // just things <= ERROR
    final Appender STDERR = new ConsoleAppender(LAYOUT, ConsoleAppender.SYSTEM_ERR);
    STDERR.addFilter(ERROR_FILTER);

    final Logger ROOT_LOGGER = Logger.getRootLogger();

    ROOT_LOGGER.removeAllAppenders();

    ROOT_LOGGER.setLevel(Level.WARN); // don't care about higher

    ROOT_LOGGER.addAppender(STDOUT);
    ROOT_LOGGER.addAppender(STDERR);
}
 
Example #17
Source File: LogHelper.java    From openpojo with Apache License 2.0 5 votes vote down vote up
public static void resetLoggers() {
  java.util.logging.LogManager.getLogManager().reset();

  BasicConfigurator.resetConfiguration();
  Properties props = new Properties();
  try {
    props.load(LogHelper.class.getResourceAsStream("/log4j.properties"));
  } catch (IOException e) {
    e.printStackTrace();
  }
  PropertyConfigurator.configure(props);
}
 
Example #18
Source File: TestEntityCSVReader.java    From JedAIToolkit with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
        BasicConfigurator.configure();
        
        String mainDirectory = "/home/gap2/Downloads/DBLP-ACM/";
        EntityCSVReader csvReader = new EntityCSVReader(mainDirectory + "DBLP2.csv");
        csvReader.setAttributeNamesInFirstRow(true);
        csvReader.setSeparator(',');
//        csvReader.setAttributesToExclude(new int[]{1});
        csvReader.setIdIndex(0);
        List<EntityProfile> profilesD1 = csvReader.getEntityProfiles();
        System.out.println("Entities from Dataset 1\t:\t" + profilesD1.size());

        csvReader = new EntityCSVReader(mainDirectory + "ACM.csv");
        csvReader.setAttributeNamesInFirstRow(true);
        csvReader.setSeparator(',');
//        csvReader.setAttributesToExclude(new int[]{1});
        csvReader.setIdIndex(0);
        List<EntityProfile> profilesD2 = csvReader.getEntityProfiles();
        System.out.println("Entities from Dataset 2\t:\t" + profilesD2.size());
        
        GtCSVReader gtCsvReader = new GtCSVReader(mainDirectory + "DBLP-ACM_perfectMapping.csv");
        gtCsvReader.setIgnoreFirstRow(true);
        gtCsvReader.setSeparator(",");
        Set<IdDuplicates> duplicates = gtCsvReader.getDuplicatePairs(profilesD1, profilesD2);
        
        System.out.println("Duplicates\t:\t" + duplicates.size());
    }
 
Example #19
Source File: CustomTokenSupplierExample.java    From dyno with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) {

        BasicConfigurator.configure();
        CustomTokenSupplierExample example = new CustomTokenSupplierExample();

        try {
            example.init();
            example.runSimpleTest();
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            example.stop();
        }
    }
 
Example #20
Source File: ApiGatewaySdkApiImporterTest.java    From aws-apigateway-importer with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();

    Injector injector = Guice.createInjector(new SwaggerApiImporterTestModule());
    client = injector.getInstance(ApiGatewaySdkApiImporter.class);
}
 
Example #21
Source File: DefaultCourseDetailsProvider.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	try {
		BasicConfigurator.configure();

		ApplicationProperties.getDefaultProperties().setProperty(
				ApplicationProperty.CustomizationExternalTerm.key(),
				BannerTermProvider.class.getName());
		ApplicationProperties.getDefaultProperties().setProperty(
				ApplicationProperty.CustomizationDefaultCourseUrl.key(),
				"https://selfservice.mypurdue.purdue.edu/prod/bzwsrch.p_catalog_detail?term=:xterm&subject=:xsubject&cnbr=:xcourseNbr&enhanced=Y");
		ApplicationProperties.getDefaultProperties().setProperty(
				ApplicationProperty.CustomizationDefaultCourseDetailsDownload.key(),
				"true");
		ApplicationProperties.getDefaultProperties().setProperty(
				ApplicationProperty.CustomizationDefaultCourseDetailsContent.key(),
				"(?idm)(<table [ ]*class=\"[a-z]*\" summary=\"This table lists the course detail for the selected term.\" .*)<table [ ]*class=\"[a-z]*\" summary=\"This is table displays line separator at end of the page.\"");
		ApplicationProperties.getDefaultProperties().setProperty(
				ApplicationProperty.CustomizationDefaultCourseDetailsModifiers.key(),
				"(?i)<a href=\"[^>]*\">\n<b>\n"+
				"(?i)</a>\n</b>\n"+
				"(?i)<span class=[\"]?fieldlabeltext[\"]?>\n<b>\n"+
				"(?i)</span>\n</b>\n"+
				"(?i) class=\"nttitle\" \n class=\"unitime-MainTableHeader\" \n"+
				"(?i) class=\"datadisplaytable\" \n class=\"unitime-MainTable\" ");
		
		System.out.println(
				"URL:" + new DefaultCourseDetailsProvider().getCourseUrl(new AcademicSessionInfo(-1l, "2010", "Spring", "PWL"), "AAE", "20300A")
				);
		
		System.out.println(
				"Details:\n" +
				new DefaultCourseDetailsProvider().getDetails(new AcademicSessionInfo(-1l, "2010", "Spring", "PWL"), "AAE", "20300A")
				);
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #22
Source File: CFindNetTest.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testProcess() {
    BasicConfigurator.configure();
    
    DicomParam[] params = { new DicomParam(Tag.PatientID, "PAT001"), new DicomParam(Tag.StudyInstanceUID),
        new DicomParam(Tag.NumberOfStudyRelatedSeries) };
    DicomNode calling = new DicomNode("WEASIS-SCU");
    DicomNode called = new DicomNode("DICOMSERVER", "dicomserver.co.uk", 11112);
    DicomState state = CFind.process(calling, called, params);
    // Should never happen
    Assert.assertNotNull(state);

    List<Attributes> items = state.getDicomRSP();
    if (items != null) {
        for (int i = 0; i < items.size(); i++) {
            Attributes item = items.get(i);
            System.out.println("===========================================");
            System.out.println("CFind Item " + (i + 1));
            System.out.println("===========================================");
            System.out.println(item.toString(100, 150));
        }
    }

    System.out.println("DICOM Status:" + state.getStatus());
    System.out.println(state.getMessage());
    // see org.dcm4che3.net.Status
    // See server log at http://dicomserver.co.uk/logs/
    Assert.assertThat(state.getMessage(), state.getStatus(), IsEqual.equalTo(Status.Success));
    Assert.assertFalse("No DICOM RSP Object", state.getDicomRSP().isEmpty());
}
 
Example #23
Source File: WatsonSim.java    From uncc2014watsonsim with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        // Read a command from the console
        System.out.print("Watsonsim CLI\n"
        		+ "Enter any natural language question to have it answered.\n"
        		+ "(Keep in mind phrasing it like Jeopardy! improves results.)\n"
        		+ "Place the correct answer after a | to check an answer.\n"
        		+ ">>> ");

	    BasicConfigurator.configure();
	    Logger.getRootLogger().setLevel(Level.INFO);
        prompt();
    }
 
Example #24
Source File: LogHelper.java    From openpojo with Apache License 2.0 5 votes vote down vote up
public static void initializeLog4J() {
  EventLogger.resetEvents(MockAppenderLog4J.class);
  BasicConfigurator.resetConfiguration();
  Properties props = new Properties();
  try {
    props.load(LogHelper.class.getResourceAsStream("/com/openpojo/utils/log/test.log4j.properties"));
  } catch (IOException e) {
    e.printStackTrace();
  }
  PropertyConfigurator.configure(props);
}
 
Example #25
Source File: Activator.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
	BasicConfigurator.configure();
	Saludo saludo = new Saludo();
	saludo.setSaludo("Hola");
	saludo.saluda();
}
 
Example #26
Source File: CGetNetTest.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testProcess() throws IOException {
    BasicConfigurator.configure();

    DicomProgress progress = new DicomProgress();
    progress.addProgressListener(progress1 -> {
        System.out.println("Remaining operations:" + progress1.getNumberOfRemainingSuboperations());
        // if (progress.getNumberOfRemainingSuboperations() == 100) {
        // progress.cancel();
        // }
    });

    /**
     * The following parameters must be changed to get a successful test.
     */

    DicomParam[] params = { new DicomParam(Tag.StudyInstanceUID, "1.2.826.0.1.3680043.11.111") };
    DicomNode calling = new DicomNode("WEASIS-SCU");
    DicomNode called = new DicomNode("DICOMSERVER", "dicomserver.co.uk", 11112);

    DicomState state = CGet.process(calling, called, progress, testFolder.newFolder("c-get"), params);

    // Should never happen
    Assert.assertNotNull(state);

    System.out.println("DICOM Status:" + state.getStatus());
    System.out.println(state.getMessage());
    System.out.println("NumberOfRemainingSuboperations:" + progress.getNumberOfRemainingSuboperations());
    System.out.println("NumberOfCompletedSuboperations:" + progress.getNumberOfCompletedSuboperations());
    System.out.println("NumberOfFailedSuboperations:" + progress.getNumberOfFailedSuboperations());
    System.out.println("NumberOfWarningSuboperations:" + progress.getNumberOfWarningSuboperations());

    // see org.dcm4che3.net.Status
    // See server log at http://dicomserver.co.uk/logs/
    Assert.assertThat(state.getMessage(), state.getStatus(), IsEqual.equalTo(Status.Success));
}
 
Example #27
Source File: LevelLogger.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
private LevelLogger() {
	File f = new File("res/conf/log4j.properties");
	if (f.exists()) {
		PropertyConfigurator.configure("res/conf/log4j.properties");
	} else {
		BasicConfigurator.configure();
	}
}
 
Example #28
Source File: LogReaderStartup.java    From TeaStore with Apache License 2.0 5 votes vote down vote up
/**
 * @see ServletContextListener#contextInitialized(ServletContextEvent)
 * @param event
 *          The servlet context event at initialization.
 */
public void contextInitialized(ServletContextEvent event) {
  startFileWriter();
  logReaderStarter = Executors.newSingleThreadScheduledExecutor();
  BasicConfigurator.configure();
  logReaderStarter.schedule(new LogReaderDaemon(), 10, TimeUnit.SECONDS);
}
 
Example #29
Source File: ApiGatewaySdkSwaggerApiImporterTest.java    From aws-apigateway-importer with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();

    Injector injector = Guice.createInjector(new SwaggerApiImporterTestModule());
    client = injector.getInstance(ApiGatewaySdkSwaggerApiImporter.class);
}
 
Example #30
Source File: DecoratorTest.java    From msgpack-rpc-java with Apache License 2.0 5 votes vote down vote up
/**
 * Test any Exception is not thrown.
 * @throws Exception
 */
@Test
public void testDecorateStopWatch()  throws Exception {

    BasicConfigurator.configure();
    EventLoop loop = EventLoop.start();
    Server svr = new Server(loop);
    svr.setDispatcherBuilder(
            new StopWatchDispatcherBuilder(svr.getDispatcherBuilder()).
                    withVerboseOutput(true)
    );
    Client c = new Client("127.0.0.1", 19850, loop);
    c.setRequestTimeout(10);

    try {
        svr.serve(new TestServer());
        svr.listen(19850);

        Value result = c.callApply("success", new Object[]{});

        assertNotNull(result);

        try{
            c.callApply("throwError", new Object[]{"StopWatchTest"});
            fail("Exception must be thrown.");
        }catch(Exception e){

        }

    } finally {
        svr.close();
        c.close();
        loop.shutdown();
    }
}