Refine search
@Test public void testNoStdout() throws UnsupportedEncodingException { System.setOut(new PrintStream(out, false, StandardCharsets.UTF_8.name())); conf.setLogOutput(listener); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.error(TEST_STR); logger.info(TEST_STR); logger.debug(TEST_STR); assertThat(out.size()).isEqualTo(0); }
/** * Create a {@link Slf4jReporter} attached to the Titan Metrics registry. * <p> * If {@code loggerName} is null, or if it is non-null but * {@link LoggerFactory#getLogger(loggerName)} returns null, then Metrics's * default Slf4j logger name is used instead. * * @param reportInterval * time to wait between writing metrics to the Slf4j * logger * @param loggerName * the name of the Slf4j logger that receives metrics */ public synchronized void addSlf4jReporter(Duration reportInterval, String loggerName) { if (null != slf4jReporter) { log.debug("Metrics Slf4jReporter already active; not creating another"); return; } Slf4jReporter.Builder b = Slf4jReporter.forRegistry(getRegistry()); if (null != loggerName) { Logger l = LoggerFactory.getLogger(loggerName); if (null != l) { b.outputTo(l); } else { log.error("Logger with name {} could not be obtained", loggerName); } } slf4jReporter = b.build(); slf4jReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
@Override public void run() { final Logger stdOutLogger = LoggerFactory.getLogger("org.apache.nifi.StdOut"); final InputStream in = process.getInputStream(); try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; while ((line = reader.readLine()) != null) { stdOutLogger.info(line); } } catch (IOException e) { defaultLogger.error("Failed to read from NiFi's Standard Out stream", e); } } });
Package logbackPackage = Package.getPackage(LOGBACK_CLASSIC); if (logbackPackage == null) { LOG.warn("Logback is not in the classpath!"); return false; Logger loggerObtained = LoggerFactory.getLogger(loggerName); if (loggerObtained == null) { LOG.warn("No logger for the name: {}", loggerName); return false; LOG.warn("No such log level: {}", logLevelUpper); return false; method.invoke(loggerObtained, params); LOG.info("LogBack level set to {} for the logger '{}'", logLevelUpper, loggerName); return true; } catch (NoClassDefFoundError e) {
final String id ) throws DocumentException, IOException, XmlPullParserException final Logger log = LoggerFactory.getLogger(Log.getName() + "[Authenticate connection for: " + localDomain + " to: " + remoteDomain + "]" ); log.debug("Remote server is offering dialback: {}, EXTERNAL SASL: {}", dialbackOffered, saslEXTERNALoffered ); log.debug( "Trying to authenticate with EXTERNAL SASL." ); result = attemptSASLexternal(connection, xpp, reader, localDomain, remoteDomain, id, openingStream); if (result == null) { log.debug( "Failed to authenticate with EXTERNAL SASL." ); } else { log.debug( "Successfully authenticated with EXTERNAL SASL." ); return result; } else { log.warn( "Unable to secure and authenticate connection: Exhausted all options." ); return null;
@Test public void testClassLogger() throws Exception { final ListAppender app = ctx.getListAppender("Class").clear(); final Logger logger = LoggerFactory.getLogger("ClassLogger"); logger.info("Ignored message contents."); logger.warn("Verifying the caller class is still correct."); logger.error("Hopefully nobody breaks me!"); final List<String> messages = app.getMessages(); assertEquals("Incorrect number of messages.", 3, messages.size()); for (final String message : messages) { assertEquals("Incorrect caller class name.", this.getClass().getName(), message); } }
/** * Create a {@link Slf4jReporter} attached to the JanusGraph Metrics registry. * <p> * If {@code loggerName} is null, or if it is non-null but * {@link LoggerFactory#getLogger(Class loggerName)} returns null, then Metrics's * default Slf4j logger name is used instead. * * @param reportInterval * time to wait between writing metrics to the Slf4j * logger * @param loggerName * the name of the Slf4j logger that receives metrics */ public synchronized void addSlf4jReporter(Duration reportInterval, String loggerName) { if (null != slf4jReporter) { log.debug("Metrics Slf4jReporter already active; not creating another"); return; } Slf4jReporter.Builder b = Slf4jReporter.forRegistry(getRegistry()); if (null != loggerName) { Logger l = LoggerFactory.getLogger(loggerName); if (null != l) { b.outputTo(l); } else { log.error("Logger with name {} could not be obtained", loggerName); } } slf4jReporter = b.build(); slf4jReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
/** * Unregister a MBean from JMX server. Errors are ignored and logged as warnings. */ public static void unregister(String name) { try { ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name)); } catch (Exception e) { LoggerFactory.getLogger(Jmx.class).warn("Can not unregister MBean [{}]", name, e); } } }
Logger logger = LoggerFactory.getLogger(Pollers.class); for (int i = 0; i < periods.length; ++i) { String period = periods[i]; result[i] = Long.parseLong(period); if (result[i] <= 0) { logger.error("Invalid polling interval: {} must be positive.", period); errors = true; logger.error("Cannot parse '{}' as a long: {}", period, e.getMessage()); errors = true; logger.info("Using a default configuration for poller intervals: {}", join(DEFAULT_PERIODS)); return DEFAULT_PERIODS;
private void initInnerTapIfNotSet(Object target, String hadoopTypeName) { if (actualTap != null) { return; } Class<?> clz = null; try { clz = Class.forName(hadoopTypeName, false, getClass().getClassLoader()); if (clz.isInstance(target)) { runningInHadoop = true; } } catch (ClassNotFoundException e) { runningInHadoop = false; } actualTap = (runningInHadoop ? new EsHadoopTap(host, port, resource, query, fields, props) : new EsLocalTap(host, port, resource, query, fields, props)); setScheme(actualTap.getScheme()); if (log.isDebugEnabled()) { log.debug(String.format("Detected %s environment; initializing [%s]", (runningInHadoop ? "Hadoop" : "local"), actualTap.getClass().getSimpleName())); } // use SLF4J just like Cascading if (!logVersion) { logVersion = true; Logger esTapLogger = LoggerFactory.getLogger(EsTap.class); esTapLogger.info(String.format("Elasticsearch Hadoop %s initialized", Version.version())); esTapLogger.warn("ES-Hadoop Cascading Integration is Deprecated as of 6.6.0 and will be removed in a later release."); } } }
final Logger log = LoggerFactory.getLogger( Log.getName() + "[Acting as Originating Server: Authenticate domain: " + localDomain + " with RS: " + remoteDomain + " (id: " + id + ")]" ); log.debug( "Authenticating domain ..." ); log.debug( "Sending dialback key and wait for the validation response..." ); StringBuilder sb = new StringBuilder(); sb.append("<db:result"); Element doc = socketReader.getElement(RemoteServerManager.getSocketTimeout(), TimeUnit.MILLISECONDS); if (doc == null) { log.debug( "Failed to authenticate domain: Time out waiting for validation response." ); return false; log.warn( "Ignoring unexpected answer while waiting for dialback validation: " + doc.asXML() );
final Logger log = LoggerFactory.getLogger( Log.getName() + "[Acting as Originating Server: Create Outgoing Session from: " + localDomain + " to RS at: " + remoteDomain + " (port: " + port+ ")]" ); log.debug( "Creating new outgoing session..." ); log.info( "Unable to create new outgoing session: Cannot create a plain socket connection with any applicable remote host." ); return null; log.debug( "Send the stream header and wait for response..." ); StringBuilder stream = new StringBuilder(); stream.append("<stream:stream"); eventType = xpp.next(); log.debug( "Got a response. Check if the remote server supports dialback..." ); log.error( "An exception occurred while creating outgoing session to remote server:", e ); log.warn( "Unable to create a new outgoing session" ); return null;
/** {@inheritDoc} */ @Override public void logHttpRequest(HttpServletRequest httpRequest, String requestName, long duration, boolean systemError, int responseSize, String loggerName) { final Logger logger = org.slf4j.LoggerFactory.getLogger(loggerName); if (logger.isInfoEnabled()) { logger.info(LOG.buildLogMessage(httpRequest, duration, systemError, responseSize)); } } }