Java Code Examples for org.slf4j.Logger#debug()
The following examples show how to use
org.slf4j.Logger#debug() .
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: UsageStatisticsManager.java From deadcode4j with Apache License 2.0 | 6 votes |
private void processResponse(HttpURLConnection urlConnection) throws IOException { final Logger logger = getLogger(); int responseCode = urlConnection.getResponseCode(); if (responseCode / 100 == 2) { logger.info("Usage statistics have been transferred."); return; } logger.info("Could not transfer usage statistics: {}/{}", responseCode, urlConnection.getResponseMessage()); if (logger.isDebugEnabled()) { InputStream inputStream = urlConnection.getInputStream(); try { List<String> response = IOUtils.readLines(inputStream, "UTF-8"); for (String line : response) { logger.debug(line); } } finally { IOUtils.closeQuietly(inputStream); } } }
Example 2
Source File: LogMessageJob.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public void runJob() throws JobExecutionException { boolean includeException = getJobExecutionContext().getMergedJobDataMap().getBooleanFromString("stacktrace"); String level = getConfiguredProperty("level"); String message = getConfiguredProperty("message"); String logger = getConfiguredProperty("logger"); Throwable throwable = null; if (includeException) { throwable = new Exception("Test Exception").fillInStackTrace(); } Logger log = LoggerFactory.getLogger(logger); if ("trace".equalsIgnoreCase(level)) { log.trace(message, throwable); } else if ("debug".equalsIgnoreCase(level)) { log.debug(message, throwable); } else if ("info".equalsIgnoreCase(level)) { log.info(message, throwable); } else if ("warn".equalsIgnoreCase(level)) { log.warn(message, throwable); } else if ("error".equalsIgnoreCase(level)) { log.error(message, throwable); } else if ("fatal".equalsIgnoreCase(level)) { log.error(fatal, message, throwable); } }
Example 3
Source File: UsageStatisticsManager.java From deadcode4j with Apache License 2.0 | 6 votes |
private void sendUsageStatistics(Map<String, String> parameters) { final Logger logger = getLogger(); HttpURLConnection urlConnection = null; try { urlConnection = openUrlConnection(); urlConnection.setAllowUserInteraction(false); urlConnection.setConnectTimeout(2000); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setInstanceFollowRedirects(false); urlConnection.setReadTimeout(5000); urlConnection.setRequestProperty("content-type", "application/x-www-form-urlencoded"); urlConnection.connect(); writeParameters(parameters, urlConnection); processResponse(urlConnection); } catch (IOException e) { logger.debug("Failed to send statistics!", e); logger.info("Failed sending usage statistics."); } finally { IOUtils.close(urlConnection); } }
Example 4
Source File: EclipseLinkOSGiSessionLogger.java From lb-karaf-examples-jpa with Apache License 2.0 | 6 votes |
/** * */ @Override public void log(SessionLogEntry sle) { Logger lg = getLogger(sle); String msg = getMessage(sle); if(lg != null && StringUtils.isNotBlank(msg)) { switch(sle.getLevel()) { case SessionLog.SEVERE : lg.error(msg); break; case SessionLog.WARNING : lg.warn (msg); break; case SessionLog.INFO : lg.info (msg); break; case SessionLog.FINE : lg.debug(msg); break; case SessionLog.FINER : lg.trace(msg); break; case SessionLog.FINEST : lg.trace(msg); break; case SessionLog.ALL : lg.trace(msg); break; default : lg.debug(msg); break; } } }
Example 5
Source File: LoadBalancer.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
private static byte[] get_mac_addr(Matcher n, String subaction, Logger log) { byte[] macaddr = new byte[6]; for (int i=0; i<6; i++) { if (n.group(i+1) != null) { try { macaddr[i] = get_byte("0x" + n.group(i+1)); } catch (NumberFormatException e) { log.debug("Invalid src-mac in: '{}' (error ignored)", subaction); return null; } } else { log.debug("Invalid src-mac in: '{}' (null, error ignored)", subaction); return null; } } return macaddr; }
Example 6
Source File: EclipseLinkOSGiSessionLogger.java From lb-karaf-examples-jpa with Apache License 2.0 | 6 votes |
/** * */ @Override public void log(SessionLogEntry sle) { Logger lg = getLogger(sle); String msg = getMessage(sle); if(lg != null && StringUtils.isNotBlank(msg)) { switch(sle.getLevel()) { case SessionLog.SEVERE : lg.error(msg); break; case SessionLog.WARNING : lg.warn (msg); break; case SessionLog.INFO : lg.info (msg); break; case SessionLog.FINE : lg.debug(msg); break; case SessionLog.FINER : lg.trace(msg); break; case SessionLog.FINEST : lg.trace(msg); break; case SessionLog.ALL : lg.trace(msg); break; default : lg.debug(msg); break; } } }
Example 7
Source File: FramebufferProvider.java From ev3dev-lang-java with MIT License | 5 votes |
/** * Initialize system framebuffer * * @param fb Framebuffer device. * @return Initialized framebuffer for the specified path. * @throws RuntimeException if no suitable framebuffer is found */ static JavaFramebuffer load(@NonNull NativeFramebuffer fb, DisplayInterface disp) throws AllImplFailedException { final Logger LOGGER = LoggerFactory.getLogger(FramebufferProvider.class); LOGGER.debug("Loading framebuffer"); ServiceLoader<FramebufferProvider> loader = ServiceLoader.load(FramebufferProvider.class); for (FramebufferProvider provider : loader) { try { JavaFramebuffer ok = provider.createFramebuffer(fb, disp); LOGGER.debug("Framebuffer '{}' is compatible", provider.getClass().getSimpleName()); return ok; } catch (IllegalArgumentException ex) { LOGGER.debug("Framebuffer '{}' is not compatible", provider.getClass().getSimpleName()); } catch (LastErrorException e) { LOGGER.warn("Framebuffer '{}' threw IOException", provider.getClass().getSimpleName()); LOGGER.warn("Message: {}", e.getLocalizedMessage()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (PrintStream chos = new PrintStream(bos)) { e.printStackTrace(chos); } LOGGER.warn(new String(bos.toByteArray(), StandardCharsets.UTF_8)); } } LOGGER.error("All framebuffer implementations failed"); throw new AllImplFailedException("No suitable framebuffer found"); }
Example 8
Source File: XodusLocalPersistence.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Override public void startExternal() { final String name = getName(); final String version = getVersion(); final int bucketCount = getBucketCount(); final StoreConfig storeConfig = getStoreConfig(); final Logger logger = getLogger(); try { final EnvironmentConfig environmentConfig = environmentUtil.createEnvironmentConfig(name); final File persistenceFolder = localPersistenceFileUtil.getVersionedLocalPersistenceFolder(name, version); for (int i = 0; i < bucketCount; i++) { final File persistenceFile = new File(persistenceFolder, name + "_" + i); final Environment environment = Environments.newContextualInstance(persistenceFile, environmentConfig); final Store store = environment.computeInTransaction(txn -> environment.openStore(name, storeConfig, txn)); buckets[i] = new Bucket(environment, store); } } catch (final ExodusException e) { logger.error("An error occurred while opening the {} persistence. Is another HiveMQ instance running?", name); logger.debug("Original Exception:", e); throw new UnrecoverableException(); } init(); }
Example 9
Source File: AbstractLoggingBoltTest.java From cognition with Apache License 2.0 | 5 votes |
@Test public void testLogDebug(@Injectable Logger logger) throws Exception { bolt.level = Level.DEBUG; new Expectations() {{ logger.debug("msg"); }}; bolt.log(logger, "msg"); }
Example 10
Source File: NYTEntitySalienceFeatureExtractor.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
@Override public List<TrainingInstance> getTrainingInstances(JCas jCas, TrainingSettings.FeatureExtractor featureExtractor, int positiveInstanceScalingFactor) throws Exception { List<TrainingInstance> trainingInstances = new ArrayList<>(); Collection<SalientEntity> salientEntities = JCasUtil.select(jCas, SalientEntity.class); Map<String, SalientEntity> salientEntityMap = new HashMap<>(); //The salient entities at this point don't have IDs. ITs better if we find the ids from the Aida Entities for(SalientEntity salientEntity : salientEntities) { salientEntityMap.put(salientEntity.getID(), salientEntity); } Logger logger = LoggerFactory.getLogger(NYTEntitySalienceFeatureExtractor.class); String docId = JCasUtil.selectSingle(jCas, DocumentMetaData.class).getDocumentId(); logger.info("[{}] Document entities: {}.", docId, salientEntityMap.size()); List<EntityInstance> entityInstances = getEntityInstances(jCas, featureExtractor); // Extract features for entities. for (EntityInstance ei : entityInstances) { String entityId = ei.getEntityId(); if(salientEntityMap.containsKey(entityId)) { Double label = salientEntityMap.get(entityId).getLabel(); // Generate the training instance with boolean label. TrainingInstance ti = new TrainingInstance(label, ei.getFeatureValues(), entityId, docId); logger.debug("[{}] for entity {} ti: {}.", docId, entityId, ti); trainingInstances.add(ti); // Scale positive examples if necessary. int addCount = (label == 1.0) ? positiveInstanceScalingFactor : 1; for (int i = 1; i < addCount; ++i) { trainingInstances.add(ti); } } } return trainingInstances; }
Example 11
Source File: Utils.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Issue a message to the log but only if the same message has not * been logged already in the same GATE session. * This is intended for explanations or warnings that should not be * repeated every time the same situation occurs. * * @param logger - the logger instance to use * @param level - a Log4J severity level for the message * @param message - the message itself * @deprecated Log4J support will be removed in future, please use SLF4J */ @Deprecated public static void logOnce (Logger logger, Object level, String message) { if(!alreadyLoggedMessages.contains(message)) { switch (level.toString()) { case "TRACE": logger.trace(message); break; case "DEBUG": logger.debug(message); break; case "INFO": logger.info(message); break; case "WARN": logger.warn(message); break; case "ERROR": case "FATAL": logger.error(message); break; default: // unknown log level, should be impossible } alreadyLoggedMessages.add(message); } }
Example 12
Source File: EvaluableCredentialCriteriaRegistry.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Clear all mappings from the registry. */ public static synchronized void clearRegistry() { Logger log = getLogger(); log.debug("Clearing evaluable criteria registry"); registry.clear(); }
Example 13
Source File: FileUtils.java From multiapps-controller with Apache License 2.0 | 5 votes |
public static void cleanUp(Path filePath, Logger logger) { if (filePath == null) { return; } File file = filePath.toFile(); if (!file.exists()) { return; } try { logger.debug(Messages.DELETING_TEMP_FILE, filePath); org.apache.commons.io.FileUtils.forceDelete(file); } catch (IOException e) { logger.warn(Messages.ERROR_DELETING_APP_TEMP_FILE, filePath.toAbsolutePath()); } }
Example 14
Source File: StaticFlowEntries.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
private static SubActionStruct decode_set_src_port(String subaction, Logger log) { SubActionStruct sa = null; Matcher n = Pattern.compile("set-src-port=((?:0x)?\\d+)").matcher(subaction); if (n.matches()) { if (n.group(1) != null) { try { short portnum = get_short(n.group(1)); OFActionTransportLayerSource action = new OFActionTransportLayerSource(); action.setTransportPort(portnum); log.debug("action {}", action); sa = new SubActionStruct(); sa.action = action; sa.len = OFActionTransportLayerSource.MINIMUM_LENGTH;; } catch (NumberFormatException e) { log.debug("Invalid src-port in: {} (error ignored)", subaction); return null; } } } else { log.debug("Invalid action: '{}'", subaction); return null; } return sa; }
Example 15
Source File: RunNiFi.java From nifi with Apache License 2.0 | 5 votes |
private boolean isProcessRunning(final String pid, final Logger logger) { try { // We use the "ps" command to check if the process is still running. final ProcessBuilder builder = new ProcessBuilder(); builder.command("ps", "-p", pid); final Process proc = builder.start(); // Look for the pid in the output of the 'ps' command. boolean running = false; String line; try (final InputStream in = proc.getInputStream(); final Reader streamReader = new InputStreamReader(in); final BufferedReader reader = new BufferedReader(streamReader)) { while ((line = reader.readLine()) != null) { if (line.trim().startsWith(pid)) { running = true; } } } // If output of the ps command had our PID, the process is running. if (running) { logger.debug("Process with PID {} is running", pid); } else { logger.debug("Process with PID {} is not running", pid); } return running; } catch (final IOException ioe) { System.err.println("Failed to determine if Process " + pid + " is running; assuming that it is not"); return false; } }
Example 16
Source File: AlbianLoggerService.java From Albianj2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void debug(String loggerName, Exception e, String format, Object... values) { Logger logger = getLogger(loggerName); if (null == logger) return; logger.debug(getDebugMsg(e, format, values)); }
Example 17
Source File: SimpleSemaphore.java From AsuraFramework with Apache License 2.0 | 4 votes |
/** * Grants a lock on the identified resource to the calling thread (blocking * until it is available). * * @return true if the lock was obtained. */ public synchronized boolean obtainLock(Connection conn, String lockName) { lockName = lockName.intern(); Logger log = getLog(); if(log.isDebugEnabled()) { log.debug( "Lock '" + lockName + "' is desired by: " + Thread.currentThread().getName()); } if (!isLockOwner(conn, lockName)) { if(log.isDebugEnabled()) { log.debug( "Lock '" + lockName + "' is being obtained: " + Thread.currentThread().getName()); } while (locks.contains(lockName)) { try { this.wait(); } catch (InterruptedException ie) { if(log.isDebugEnabled()) { log.debug( "Lock '" + lockName + "' was not obtained by: " + Thread.currentThread().getName()); } } } if(log.isDebugEnabled()) { log.debug( "Lock '" + lockName + "' given to: " + Thread.currentThread().getName()); } getThreadLocks().add(lockName); locks.add(lockName); } else if(log.isDebugEnabled()) { log.debug( "Lock '" + lockName + "' already owned by: " + Thread.currentThread().getName() + " -- but not owner!", new Exception("stack-trace of wrongful returner")); } return true; }
Example 18
Source File: SFTPLogger.java From sftp-fs with Apache License 2.0 | 4 votes |
public static void disconnectedChannel(Logger logger, String channelId) { if (logger != null && logger.isDebugEnabled()) { logger.debug(String.format(getMessage("log.disconnectedChannel"), channelId)); //$NON-NLS-1$ } }
Example 19
Source File: Example.java From eclair with Apache License 2.0 | 4 votes |
void simplePlain() { Logger logger = LoggerFactory.getLogger("ru.tinkoff.eclair.example.Example.simple"); logger.debug(">"); // logic logger.debug("<"); }
Example 20
Source File: Configuration.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Adds an object provider to this configuration. * * @param providerName the name of the object provider, corresponding to the element name or type name that the * builder, marshaller, and unmarshaller operate on * @param builder the builder for that given provider * @param marshaller the marshaller for the provider * @param unmarshaller the unmarshaller for the provider * @param configuration optional XML configuration snippet * * @deprecated this method is deprecated with no replacement */ public static void registerObjectProvider(QName providerName, XMLObjectBuilder builder, Marshaller marshaller, Unmarshaller unmarshaller, Element configuration) { Logger log = getLogger(); log.debug("Registering new builder, marshaller, and unmarshaller for {}", providerName); if (configuration != null) { configuredObjectProviders.put(providerName, configuration); } builderFactory.registerBuilder(providerName, builder); marshallerFactory.registerMarshaller(providerName, marshaller); unmarshallerFactory.registerUnmarshaller(providerName, unmarshaller); }