Java Code Examples for org.apache.logging.log4j.core.config.Configurator#setRootLevel()

The following examples show how to use org.apache.logging.log4j.core.config.Configurator#setRootLevel() . 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: KmerGenerator.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
public static void main(@NotNull final String[] args) throws ParseException
{
    final Options options = new Options();
    options.addOption(DATA_OUTPUT_DIR, true, "Output directory");
    options.addOption(GENE_TRANSCRIPTS_DIR, true, "Ensembl gene transcript data cache directory");
    options.addOption(KMER_INPUT_FILE, true, "File specifying locations to produce K-mers for");
    options.addOption(REF_GENOME_FILE, true, "Ref genome file");

    final CommandLineParser parser = new DefaultParser();
    final CommandLine cmd = parser.parse(options, args);

    Configurator.setRootLevel(Level.DEBUG);

    final String outputDir = formOutputPath(cmd.getOptionValue(DATA_OUTPUT_DIR));
    final String kmerInputFile = formOutputPath(cmd.getOptionValue(KMER_INPUT_FILE));
    final String refGenomeFile = formOutputPath(cmd.getOptionValue(REF_GENOME_FILE));

    KmerGenerator kmerGenerator = new KmerGenerator(refGenomeFile, kmerInputFile, outputDir);
    kmerGenerator.generateKmerData();
}
 
Example 2
Source File: BachelorApplication.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
public static void main(final String... args)
{
    final Options options = createOptions();

    try
    {
        final CommandLine cmd = createCommandLine(options, args);

        if (cmd.hasOption(LOG_DEBUG))
            Configurator.setRootLevel(Level.DEBUG);

        BachelorApplication bachelorApp = new BachelorApplication(cmd);
        bachelorApp.run();
    }
    catch (Exception e)
    {
        LOGGER.error("config errors: {}", e.toString());
        e.printStackTrace();
    }
}
 
Example 3
Source File: GameBootstrapper.java    From 2018-TowerDefence with MIT License 6 votes vote down vote up
private void prepareGame(Config config) throws Exception {
    String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
    gameName = FileUtils.getAbsolutePath(config.roundStateOutputLocation) + "/" + timeStamp;

    List<Player> players = new ArrayList<>();

    players.add(parsePlayer(config.playerAConfig, "A", config));
    players.add(parsePlayer(config.playerBConfig, "B", config));

    gameEngineRunner.preparePlayers(players);
    gameEngineRunner.prepareGameMap();

    if (config.isVerbose) {
        Configurator.setRootLevel(Level.DEBUG);
    } else {
        Configurator.setRootLevel(Level.ERROR);
    }
}
 
Example 4
Source File: FunctionApiV3ResourceTest.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "Function language runtime is either not set or cannot be determined")
public void testCreateFunctionWithoutSettingRuntime() throws Exception {
    Configurator.setRootLevel(Level.DEBUG);

    URL fileUrl = getClass().getClassLoader().getResource("test_worker_config.yml");
    File file = Paths.get(fileUrl.toURI()).toFile();
    String fileLocation = file.getAbsolutePath();
    String filePackageUrl = "file://" + fileLocation;
    when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(false);

    FunctionConfig functionConfig = new FunctionConfig();
    functionConfig.setTenant(tenant);
    functionConfig.setNamespace(namespace);
    functionConfig.setName(function);
    functionConfig.setClassName(className);
    functionConfig.setParallelism(parallelism);
    functionConfig.setCustomSerdeInputs(topicsToSerDeClassName);
    functionConfig.setOutput(outputTopic);
    functionConfig.setOutputSerdeClassName(outputSerdeClassName);
    resource.registerFunction(tenant, namespace, function, null, null, filePackageUrl, functionConfig, null, null);

}
 
Example 5
Source File: FunctionApiV3ResourceTest.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisterFunctionFileUrlWithValidSinkClass() throws Exception {
    Configurator.setRootLevel(Level.DEBUG);

    URL fileUrl = getClass().getClassLoader().getResource("test_worker_config.yml");
    File file = Paths.get(fileUrl.toURI()).toFile();
    String fileLocation = file.getAbsolutePath();
    String filePackageUrl = "file://" + fileLocation;
    when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(false);

    FunctionConfig functionConfig = new FunctionConfig();
    functionConfig.setTenant(tenant);
    functionConfig.setNamespace(namespace);
    functionConfig.setName(function);
    functionConfig.setClassName(className);
    functionConfig.setParallelism(parallelism);
    functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
    functionConfig.setCustomSerdeInputs(topicsToSerDeClassName);
    functionConfig.setOutput(outputTopic);
    functionConfig.setOutputSerdeClassName(outputSerdeClassName);
    resource.registerFunction(tenant, namespace, function, null, null, filePackageUrl, functionConfig, null, null);

}
 
Example 6
Source File: SourceApiV3ResourceTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "Source test-source already exists")
public void testRegisterExistedSource() throws IOException {
    try {
        Configurator.setRootLevel(Level.DEBUG);

        when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(source))).thenReturn(true);

        registerDefaultSource();
    } catch (RestException re){
        assertEquals(re.getResponse().getStatusInfo(), Response.Status.BAD_REQUEST);
        throw re;
    }
}
 
Example 7
Source File: CohortAnalyser.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public static void main(@NotNull final String[] args) throws ParseException
{
    final Options options = CohortConfig.createCmdLineOptions();
    final CommandLineParser parser = new DefaultParser();
    final CommandLine cmd = parser.parse(options, args);

    if(!isValid(cmd))
    {
        ISF_LOGGER.error("missing or invalid config options");
        return;
    }

    if (cmd.hasOption(LOG_DEBUG))
    {
        Configurator.setRootLevel(Level.DEBUG);
    }

    CohortAnalyser cohortAnalyser = new CohortAnalyser(cmd);

    if(!cohortAnalyser.load())
    {
        ISF_LOGGER.info("Isofox cohort analyser failed");
        return;
    }

    ISF_LOGGER.info("Isofox cohort analyser complete");
}
 
Example 8
Source File: ExternalDBFilters.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public static void main(final String... args) throws ParseException
{
    final Options options = new Options();
    options.addOption(CONFIG_XML, true, "XML with genes, black and white lists");
    options.addOption(OUTPUT_DIR, true, "Optional, directory to where the output ClinVar filter file will be written to.");
    options.addOption(CREATE_FILTER_FILE, true, "Input file to create the ClinVar db filters");
    options.addOption(LOG_DEBUG, false, "Sets log level to Debug, off by default");

    final CommandLine cmd = new DefaultParser().parse(options, args);

    if (!cmd.hasOption(CONFIG_XML))
    {
        LOGGER.error("No " + CONFIG_XML + " provided to ExternalDBFilters!");
        return;
    }

    if (cmd.hasOption(LOG_DEBUG))
        Configurator.setRootLevel(Level.DEBUG);

    LOGGER.info("Building ClinVar filter file");

    Map<String, Program> configMap = Maps.newHashMap();
    loadXML(Paths.get(cmd.getOptionValue(CONFIG_XML)), configMap);

    Program program = configMap.values().iterator().next();

    String filterInputFile = cmd.getOptionValue(CREATE_FILTER_FILE);
    ExternalDBFilters filterFileBuilder = new ExternalDBFilters(filterInputFile);

    String outputDir = cmd.getOptionValue(OUTPUT_DIR, "");
    filterFileBuilder.createFilterFile(program, outputDir);

    LOGGER.info("Filter file creation complete");
}
 
Example 9
Source File: SinkApiV3ResourceTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "Sink test-sink already exists")
public void testRegisterExistedSink() throws IOException {
    try {
        Configurator.setRootLevel(Level.DEBUG);

        when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);

        registerDefaultSink();
    } catch (RestException re){
        assertEquals(re.getResponse().getStatusInfo(), Response.Status.BAD_REQUEST);
        throw re;
    }
}
 
Example 10
Source File: LinxTester.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public void logVerbose(boolean toggle)
{
    Config.LogVerbose = toggle;

    if(toggle)
        Configurator.setRootLevel(Level.TRACE);

    Analyser.getChainFinder().setLogVerbose(toggle);
}
 
Example 11
Source File: HttpSimpleTableServer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) {
    JMeterUtils.loadJMeterProperties("jmeter.properties");
    String dataset = JMeterUtils.getPropDefault(
            "jmeterPlugin.sts.datasetDirectory",
            HttpSimpleTableControl.DEFAULT_DATA_DIR);
    int port = JMeterUtils.getPropDefault("jmeterPlugin.sts.port",
            HttpSimpleTableControl.DEFAULT_PORT);
    boolean timestamp = JMeterUtils.getPropDefault(
            "jmeterPlugin.sts.addTimestamp",
            HttpSimpleTableControl.DEFAULT_TIMESTAMP);

    // default level
    Configurator.setLevel(log.getName(), Level.INFO);
    // allow override by system properties
    
    String loglevelStr = JMeterUtils.getPropDefault(
            "loglevel", HttpSimpleTableControl.DEFAULT_LOG_LEVEL);
    System.out.println("loglevel=" + loglevelStr);
    
    //Configurator.setLevel(log.getName(), Level.toLevel(loglevelStr));
    Configurator.setRootLevel(Level.toLevel(loglevelStr));
    Configurator.setLevel(log.getName(), Level.toLevel(loglevelStr));
    bStartFromMain=true;
    
    HttpSimpleTableServer serv = new HttpSimpleTableServer(port, timestamp,
            dataset);

    log.info("Creating HttpSimpleTable ...");
    log.info("------------------------------");
    log.info("SERVER_PORT : " + port);
    log.info("DATASET_DIR : " + dataset);
    log.info("TIMESTAMP : " + timestamp);
    log.info("------------------------------");
    log.info("STS_VERSION : " + STS_VERSION);
    ServerRunner.executeInstance(serv);
}
 
Example 12
Source File: ExpectedRatesTest.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testExpectationMaxFit()
{
    Configurator.setRootLevel(Level.DEBUG);

    int categoryCount = 3;
    int transCount = 2;

    SigMatrix sigs = new SigMatrix(categoryCount, transCount);
    double[] transSig1 = {0.2, 0.8, 0};
    double[] transSig2 = {0.4, 0, 0.6};

    sigs.setCol(0, transSig1);
    sigs.setCol(1, transSig2);

    double[] transCounts = new double[categoryCount];

    transCounts[0] = 5;
    transCounts[1] = 4;
    transCounts[2] = 6;

    double[] allocations = ExpectationMaxFit.performFit(transCounts, sigs);

    assertEquals(5.002, allocations[0], 0.001);
    assertEquals(9.998, allocations[1], 0.001);

    transCounts[0] = 5;
    transCounts[1] = 4;
    transCounts[2] = 7;

    allocations = ExpectationMaxFit.performFit(transCounts, sigs);

    assertEquals(4.905, allocations[0], 0.001);
    assertEquals(11.095, allocations[1], 0.001);

}
 
Example 13
Source File: LoggerTest.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Test
public void debugChangeRootLevel() {
    logger.debug("Debug message 1");
    assertEventCount(app.getEvents(), 1);
    Configurator.setRootLevel(Level.OFF);
    logger.debug("Debug message 2");
    assertEventCount(app.getEvents(), 1);
    Configurator.setRootLevel(Level.DEBUG);
    logger.debug("Debug message 3");
    assertEventCount(app.getEvents(), 2);
}
 
Example 14
Source File: FunctionApiV2ResourceTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateFunctionWithUrl() throws Exception {
    Configurator.setRootLevel(Level.DEBUG);

    URL fileUrl = getClass().getClassLoader().getResource("test_worker_config.yml");
    File file = Paths.get(fileUrl.toURI()).toFile();
    String fileLocation = file.getAbsolutePath();
    String filePackageUrl = "file://" + fileLocation;

    FunctionConfig functionConfig = new FunctionConfig();
    functionConfig.setOutput(outputTopic);
    functionConfig.setOutputSerdeClassName(outputSerdeClassName);
    functionConfig.setTenant(tenant);
    functionConfig.setNamespace(namespace);
    functionConfig.setName(function);
    functionConfig.setClassName(className);
    functionConfig.setParallelism(parallelism);
    functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
    functionConfig.setCustomSerdeInputs(topicsToSerDeClassName);

    when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(true);

    try {
        resource.updateFunction(
                tenant,
                namespace,
                function,
                null,
                null,
                filePackageUrl,
                JsonFormat.printer().print(FunctionConfigUtils.convert(functionConfig, null)),
                null);
    } catch (InvalidProtocolBufferException e) {
        throw new RuntimeException(e);
    }

}
 
Example 15
Source File: SvSimulator.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public static void main(@NotNull final String[] args) throws ParseException
{
    final Options options = createBasicOptions();
    final CommandLine cmd = createCommandLine(args, options);

    if (cmd.hasOption(LOG_DEBUG))
    {
        Configurator.setRootLevel(Level.DEBUG);
    }

    String outputDir = formOutputPath(cmd.getOptionValue(DATA_OUTPUT_DIR));

    SvSimulator simulator = new SvSimulator(cmd, outputDir);
    simulator.run();
}
 
Example 16
Source File: SinkApiV3ResourceTest.java    From pulsar with Apache License 2.0 4 votes vote down vote up
@Test
public void testUpdateSinkWithUrl() throws Exception {
    Configurator.setRootLevel(Level.DEBUG);

    String filePackageUrl = "file://" + JAR_FILE_PATH;

    SinkConfig sinkConfig = new SinkConfig();
    sinkConfig.setTopicToSerdeClassName(topicsToSerDeClassName);
    sinkConfig.setTenant(tenant);
    sinkConfig.setNamespace(namespace);
    sinkConfig.setName(sink);
    sinkConfig.setClassName(className);
    sinkConfig.setParallelism(parallelism);

    when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);
    mockStatic(ConnectorUtils.class);
    doReturn(CassandraStringSink.class.getName()).when(ConnectorUtils.class);
    ConnectorUtils.getIOSinkClass(any(NarClassLoader.class));

    mockStatic(ClassLoaderUtils.class);

    mockStatic(FunctionCommon.class);
    doReturn(String.class).when(FunctionCommon.class);
    FunctionCommon.getSinkType(anyString(), any(NarClassLoader.class));
    PowerMockito.when(FunctionCommon.class, "extractFileFromPkgURL", any()).thenCallRealMethod();

    doReturn(mock(NarClassLoader.class)).when(FunctionCommon.class);
    FunctionCommon.extractNarClassLoader(any(), any(), any());

    doReturn(ATLEAST_ONCE).when(FunctionCommon.class);
    FunctionCommon.convertProcessingGuarantee(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE);

    this.mockedFunctionMetaData = FunctionMetaData.newBuilder().setFunctionDetails(createDefaultFunctionDetails()).build();
    when(mockedManager.getFunctionMetaData(any(), any(), any())).thenReturn(mockedFunctionMetaData);

    resource.updateSink(
        tenant,
        namespace,
            sink,
        null,
        null,
        filePackageUrl,
        sinkConfig,
            null, null, null);
}
 
Example 17
Source File: PackageTool.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressForbidden(reason = "Need to turn off logging, and SLF4J doesn't seem to provide for a way.")
public PackageTool() {
  // Need a logging free, clean output going through to the user.
  Configurator.setRootLevel(Level.OFF);
}
 
Example 18
Source File: LoggingConfiguration.java    From apm-agent-java with Apache License 2.0 4 votes vote down vote up
private static void setLogLevel(@Nullable LogLevel level) {
    if (level == null) {
        level = LogLevel.INFO;
    }
    Configurator.setRootLevel(org.apache.logging.log4j.Level.toLevel(level.toString(), org.apache.logging.log4j.Level.INFO));
}
 
Example 19
Source File: CommandLineMain.java    From BlockMap with MIT License 4 votes vote down vote up
public void runAll() {
	if (verbose) {
		Configurator.setRootLevel(Level.DEBUG);
	}
}