List of usage examples for java.util.logging Logger info
public void info(Supplier<String> msgSupplier)
From source file:org.apache.sling.extensions.logback.integration.ITJULIntegration.java
/** * Checks the default settings. It runs the bundle with minimum dependencies *//*from w w w . j a va2s . c o m*/ @Test public void testJULLogging() throws Exception { java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("foo.jul.1"); org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger("foo.jul.1"); assertEquals(java.util.logging.Level.FINEST, julLogger.getLevel()); assertTrue(slf4jLogger.isTraceEnabled()); //Now add an appender and see if JUL logs are handled TestAppender ta = new TestAppender(); Dictionary<String, Object> props = new Hashtable<String, Object>(); String[] loggers = { "foo.jul.1:INFO", }; props.put("loggers", loggers); ServiceRegistration sr = bundleContext.registerService(Appender.class.getName(), ta, props); delay(); //Level should be INFO now assertEquals(java.util.logging.Level.INFO, julLogger.getLevel()); julLogger.info("Info message"); julLogger.fine("Fine message"); assertEquals(1, ta.events.size()); }
From source file:org.usrz.libs.logging.LevelTraceTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasLastEvent("at Finest level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasLastEvent("at Finer level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasLastEvent("at Fine level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasLastEvent("at Config level"); assertTrue(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelDebugTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasLastEvent("at Fine level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasLastEvent("at Config level"); assertTrue(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelInfoTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasLastEvent("at Config level"); assertTrue(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelErrorTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasNoLastEvent("at Config level"); assertFalse(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasNoLastEvent("at Info level"); assertFalse(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasNoLastEvent("at Warning level"); assertFalse(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelWarningTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasNoLastEvent("at Config level"); assertFalse(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasNoLastEvent("at Info level"); assertFalse(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:at.tuwien.ifs.somtoolbox.visualization.PMatrix.java
private int calculateParetoRadiusPercentile(InputVectorDistanceMatrix distances, DoubleMatrix1D percentiles) { // the paper describes the 18th percentile as a good start value for gaussian distributions int percentile = 18; double radius; // variables needed for the search int last_percentile = percentile; double diff = 0.0; double last_diff = 1.0; double median_size; boolean stop = false; double upper_size = 1.0; double lower_size = 0.0; // upper and lower search boundaries for the percentiles double upper_percentile = 50; double lower_percentile = 2; Logger log = Logger.getLogger("at.tuwien.ifs.somtoolbox"); while (!stop) { // get current radius from the percentile radius = percentiles.getQuick(percentile); // compute densities with this radius DoubleMatrix1D densities = getAllDensities(distances, radius); // median percentage of points in spheres if (densities.size() != 0) { double median = VectorTools.median(densities.toArray()); double mean = densities.zSum() / densities.size(); log.info("Mean: " + mean + " median: " + median); median_size = Math.max(median, mean) / distances.columns(); } else {//from w w w .ja v a 2s.co m median_size = 0; } log.fine("spheres for " + percentile + "%-tile contain on average " + Math.round(median_size * 100) + "% of the data"); // compute difference of median size to the defined optimum diff = median_size - PARETO_SIZE; // stop if last step was 1, or the defined upper/lower stopping criterion is reached stop = Math.abs(percentile - last_percentile) == 1 || percentile == upper_percentile || percentile == lower_percentile; if (!stop) { // iterate last_percentile = percentile; last_diff = diff; // adjust percentile towards optimum with linear interpolation if (diff > 0) { upper_percentile = percentile; upper_size = median_size; } else { lower_percentile = percentile; lower_size = median_size; } // compute the estimated position of pareto size in the current search interval double pest = (PARETO_SIZE - lower_size) / (upper_size - lower_size) * (upper_percentile - lower_percentile) + lower_percentile; // step towards the estimated position double step = pest - percentile; // always go at least 1 resp. -1 if (step > 0) { step = Math.max(step, 1); } else { step = Math.min(step, -1); } percentile = percentile + (int) Math.round(step); } else { // if it is better, revert to the last percentile before we stopped if (Math.abs(diff) > Math.abs(last_diff)) { percentile = last_percentile; } } } log.info("P-Matrix: " + percentile + "%tile chosen."); return percentile; }
From source file:org.apache.sling.commons.log.logback.integration.ITJULIntegration.java
/** * Checks the default settings. It runs the bundle with minimum dependencies *///from w ww.j a v a 2 s . c o m @Test public void testJULLogging() throws Exception { java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("foo.jul.1"); org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger("foo.jul.1"); assertEquals(java.util.logging.Level.FINEST, julLogger.getLevel()); assertTrue(slf4jLogger.isTraceEnabled()); // Now add an appender and see if JUL logs are handled TestAppender ta = new TestAppender(); Dictionary<String, Object> props = new Hashtable<String, Object>(); String[] loggers = { "foo.jul.1", }; ch.qos.logback.classic.Logger bar = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(loggers[0]); bar.setLevel(Level.INFO); props.put("loggers", loggers); ServiceRegistration sr = bundleContext.registerService(Appender.class.getName(), ta, props); delay(); // Level should be INFO now assertEquals(java.util.logging.Level.INFO, julLogger.getLevel()); julLogger.info("Info message"); julLogger.fine("Fine message"); assertEquals(1, ta.events.size()); }
From source file:itemsetmining.itemset.ItemsetTree.java
/** * Print statistics about the time and maximum memory usage for the * construction of the itemset tree.// w w w . j av a2 s . com */ public void printStatistics(final Logger logger) { System.gc(); logger.info("========== MEMORY EFFICIENT ITEMSET TREE CONSTRUCTION - STATS ============\n"); logger.info(" Tree construction time ~: " + (endTimestamp - startTimestamp) + " ms\n"); logger.info(" Max memory: " + MemoryLogger.getInstance().getMaxMemory() + " MB\n"); nodeCount = 0; totalItemCountInNodes = 0; sumBranchesLength = 0; totalNumberOfBranches = 0; recursiveStats(root, 1); logger.info(" Node count: " + nodeCount + "\n"); logger.info(" No. items: " + totalItemCountInNodes + ", avg items per node: " + totalItemCountInNodes / ((double) nodeCount) + "\n"); logger.info("=====================================\n"); }
From source file:edu.harvard.iq.dataverse.harvest.client.HarvesterServiceBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public Long processRecord(DataverseRequest dataverseRequest, Logger hdLogger, PrintWriter importCleanupLog, OaiHandler oaiHandler, String identifier, MutableBoolean recordErrorOccurred, MutableLong processedSizeThisBatch, List<String> deletedIdentifiers) { String errMessage = null;//from ww w . j ava 2s.c om Dataset harvestedDataset = null; logGetRecord(hdLogger, oaiHandler, identifier); File tempFile = null; try { FastGetRecord record = oaiHandler.runGetRecord(identifier); errMessage = record.getErrorMessage(); if (errMessage != null) { hdLogger.log(Level.SEVERE, "Error calling GetRecord - " + errMessage); } else if (record.isDeleted()) { hdLogger.info( "Deleting harvesting dataset for " + identifier + ", per the OAI server's instructions."); Dataset dataset = datasetService .getDatasetByHarvestInfo(oaiHandler.getHarvestingClient().getDataverse(), identifier); if (dataset != null) { hdLogger.info("Deleting dataset " + dataset.getGlobalId()); deleteHarvestedDataset(dataset, dataverseRequest, hdLogger); // TODO: // check the status of that Delete - see if it actually succeeded deletedIdentifiers.add(identifier); } else { hdLogger.info("No dataset found for " + identifier + ", skipping delete. "); } } else { hdLogger.info("Successfully retrieved GetRecord response."); tempFile = record.getMetadataFile(); PrintWriter cleanupLog; harvestedDataset = importService.doImportHarvestedDataset(dataverseRequest, oaiHandler.getHarvestingClient(), identifier, oaiHandler.getMetadataPrefix(), record.getMetadataFile(), importCleanupLog); hdLogger.fine("Harvest Successful for identifier " + identifier); hdLogger.fine("Size of this record: " + record.getMetadataFile().length()); processedSizeThisBatch.add(record.getMetadataFile().length()); } } catch (Throwable e) { logGetRecordException(hdLogger, oaiHandler, identifier, e); errMessage = "Caught exception while executing GetRecord on " + identifier; //logException(e, hdLogger); } finally { if (tempFile != null) { // temporary - let's not delete the temp metadata file if anything went wrong, for now: if (errMessage == null) { try { tempFile.delete(); } catch (Throwable t) { } ; } } } // TODO: the message below is taken from DVN3; - figure out what it means... // // If we got an Error from the OAI server or an exception happened during import, then // set recordErrorOccurred to true (if recordErrorOccurred is being used) // otherwise throw an exception (if recordErrorOccurred is not used, i.e null) if (errMessage != null) { if (recordErrorOccurred != null) { recordErrorOccurred.setValue(true); } else { throw new EJBException(errMessage); } } return harvestedDataset != null ? harvestedDataset.getId() : null; }