use of org.apache.logging.log4j.Logger in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNCreationUtils method subsetReadCountsToUsableTargets.
/**
* Subsets targets in the input count to the usable ones based on the percentile threshold indicated
* by the user.
*
* <p>
* It returns a pair of object, where the left one is the updated read-counts with only the usable
* targets, and the right one is the corresponding target factors.
* </p>
*
* @param readCounts the input read-counts.
* @param targetFactorPercentileThreshold the minimum median count percentile under which targets are not considered useful.
* @return never {@code null}.
*/
@VisibleForTesting
static Pair<ReadCountCollection, double[]> subsetReadCountsToUsableTargets(final ReadCountCollection readCounts, final double targetFactorPercentileThreshold, final Logger logger) {
final double[] targetFactors = calculateTargetFactors(readCounts);
final double threshold = new Percentile(targetFactorPercentileThreshold).evaluate(targetFactors);
final List<Target> targetByIndex = readCounts.targets();
final Set<Target> result = IntStream.range(0, targetFactors.length).filter(i -> targetFactors[i] >= threshold).mapToObj(targetByIndex::get).collect(Collectors.toCollection(LinkedHashSet::new));
if (result.size() == targetByIndex.size()) {
logger.info(String.format("All %d targets are kept", targetByIndex.size()));
return new ImmutablePair<>(readCounts, targetFactors);
} else {
final int discardedCount = targetFactors.length - result.size();
logger.info(String.format("Discarded %d target(s) out of %d with factors below %.2g (%.2f percentile)", discardedCount, targetFactors.length, threshold, targetFactorPercentileThreshold));
final double[] targetFactorSubset = DoubleStream.of(targetFactors).filter(i -> i >= threshold).toArray();
return new ImmutablePair<>(readCounts.subsetTargets(result), targetFactorSubset);
}
}
use of org.apache.logging.log4j.Logger in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class log4j2Test method testLog4j2.
@Test
public void testLog4j2() throws InterruptedException, MQClientException {
Logger logger = LogManager.getLogger("test");
for (int i = 0; i < 50; i++) {
logger.info("log4j2 log message " + i);
}
int received = consumeMessages(30, "log4j2", 30);
Assert.assertTrue(received > 20);
}
use of org.apache.logging.log4j.Logger in project SpongeForge by SpongePowered.
the class TerminateVM method terminate.
@SuppressWarnings("unchecked")
public static void terminate(String masqueradePackage, int status) {
final Logger log = LogManager.getLogger("Sponge");
try {
log.info("Attempting to shut down the VM cleanly");
FMLCommonHandler.instance().exitJava(status, true);
} catch (Throwable th) {
log.info("Clean shutdown failed, forcing VM termination");
}
IExitHandler handler = null;
try {
MasqueradeClassLoader cl = new MasqueradeClassLoader(Launch.classLoader, masqueradePackage);
Constructor<IExitHandler> ctor = ((Class<IExitHandler>) Class.forName(cl.getClassName(), true, cl)).getDeclaredConstructor();
ctor.setAccessible(true);
handler = ctor.newInstance();
} catch (Throwable th) {
log.catching(th);
handler = new TerminateVM();
}
handler.exit(status);
}
use of org.apache.logging.log4j.Logger in project tutorials by eugenp.
the class MyServiceTest method testRollingFileAppender.
@Test
public void testRollingFileAppender() {
Logger rfLogger = LogManager.getLogger("RollingFileLogger");
rfLogger.info("Json Message 1");
rfLogger.info("Json Message 2");
}
use of org.apache.logging.log4j.Logger in project tutorials by eugenp.
the class MyServiceTest method testProgrammaticConfig.
@Test
public void testProgrammaticConfig() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
PatternLayout layout = PatternLayout.newBuilder().withConfiguration(config).withPattern("%d{HH:mm:ss.SSS} %level %msg%n").build();
Appender appender = FileAppender.newBuilder().setConfiguration(config).withName("programmaticFileAppender").withLayout(layout).withFileName("java.log").build();
appender.start();
config.addAppender(appender);
AppenderRef ref = AppenderRef.createAppenderRef("programmaticFileAppender", null, null);
AppenderRef[] refs = new AppenderRef[] { ref };
LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "programmaticLogger", "true", refs, null, config, null);
loggerConfig.addAppender(appender, null, null);
config.addLogger("programmaticLogger", loggerConfig);
ctx.updateLoggers();
Logger pLogger = LogManager.getLogger("programmaticLogger");
pLogger.info("Programmatic Logger Message");
}
Aggregations