public static void setDelegating(final boolean newValue) { StatusLogger.getLogger().debug("Setting delegating to {}", newValue); delegating = newValue; }
@BeforeClass public static void beforeClass() throws Exception { final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG); String content = new String(Files.readAllBytes(src), UTF_8); final Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, CRON_DELAY); remainingTime = cal.getTimeInMillis() - System.currentTimeMillis(); cronExpression = String.format("%d %d %d * * ?", cal.get(Calendar.SECOND), cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY)); content = content.replace("@CRON_EXPR@", cronExpression); Files.write(FileSystems.getDefault() .getPath(TARGET_TEST_CLASSES, CONFIG_TARGET), content.getBytes(UTF_8)); StatusLogger.getLogger().debug("Cron expression will be " + cronExpression + " in " + remainingTime + "ms"); }
private static void register(final MBeanServer mbs, final Object mbean, final ObjectName objectName) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { LOGGER.debug("Registering MBean {}", objectName); mbs.registerMBean(mbean, objectName); } }
private SSLContext createSslContextWithDefaultKeyManagerFactory() throws TrustStoreConfigurationException { try { return createSslContext(true, false); } catch (final KeyStoreConfigurationException dummy) { LOGGER.debug("Exception occured while using default keystore. This should be a BUG"); return null; } }
private SSLContext createSslContextWithDefaultTrustManagerFactory() throws KeyStoreConfigurationException { try { return createSslContext(false, true); } catch (final TrustStoreConfigurationException dummy) { LOGGER.debug("Exception occured while using default truststore. This should be a BUG"); return null; } }
private SSLContext createSslContextWithKeyStoreFailure() { SSLContext context; try { context = createSslContextWithDefaultKeyManagerFactory(); LOGGER.debug("Creating SSLContext with default keystore"); } catch (final TrustStoreConfigurationException e) { context = createDefaultSslContext(); LOGGER.debug("Creating SSLContext with default configuration"); } return context; }
private SSLContext createSslContextWithTrustStoreFailure() { SSLContext context; try { context = createSslContextWithDefaultTrustManagerFactory(); LOGGER.debug("Creating SSLContext with default truststore"); } catch (final KeyStoreConfigurationException e) { context = createDefaultSslContext(); LOGGER.debug("Creating SSLContext with default configuration"); } return context; }
public static void setDelegating(final boolean newValue) { StatusLogger.getLogger().debug("Setting delegating to {}", newValue); delegating = newValue; }
/** * Constructs a Log4jContextFactory using the provided ContextSelector and ShutdownRegistrationStrategy. * * @param selector the selector to use * @param shutdownCallbackRegistry the ShutdownRegistrationStrategy to use * @since 2.1 */ public Log4jContextFactory(final ContextSelector selector, final ShutdownCallbackRegistry shutdownCallbackRegistry) { this.selector = Objects.requireNonNull(selector, "No ContextSelector provided"); this.shutdownCallbackRegistry = Objects.requireNonNull(shutdownCallbackRegistry, "No ShutdownCallbackRegistry provided"); LOGGER.debug("Using ShutdownCallbackRegistry {}", shutdownCallbackRegistry.getClass()); initializeShutdownCallbackRegistry(); }
@SuppressWarnings("synthetic-access") @Override public void propertyChange(final PropertyChangeEvent evt) { StatusLogger.getLogger().debug("LogService responding to a property change event. Property name is {}.", evt.getPropertyName()); if (evt.getPropertyName().equals(LoggerContext.PROPERTY_CONFIG)) { configureFastLoggerDelegating(); } } }
/** * Unregister all log4j MBeans from the platform MBean server. */ public static void unregisterMBeans() { if (isJmxDisabled()) { LOGGER.debug("JMX disabled for Log4j2. Not unregistering MBeans."); return; } final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); unregisterMBeans(mbs); }
public static void reregisterMBeansAfterReconfigure() { // avoid creating Platform MBean Server if JMX disabled if (isJmxDisabled()) { LOGGER.debug("JMX disabled for Log4j2. Not registering MBeans."); return; } final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); reregisterMBeansAfterReconfigure(mbs); }
@Override public void setConfigText(final String configText, final String charsetName) { LOGGER.debug("---------"); LOGGER.debug("Remote request to reconfigure from config text."); try { final InputStream in = new ByteArrayInputStream(configText.getBytes(charsetName)); final ConfigurationSource source = new ConfigurationSource(in); final Configuration updated = ConfigurationFactory.getInstance().getConfiguration(loggerContext, source); loggerContext.start(updated); LOGGER.debug("Completed remote request to reconfigure from config text."); } catch (final Exception ex) { final String msg = "Could not reconfigure from config text"; LOGGER.error(msg, ex); throw new IllegalArgumentException(msg, ex); } }
/** * Unregisters all MBeans associated with the specified logger context (including MBeans for {@code LoggerConfig}s * and {@code Appender}s from the platform MBean server. * * @param loggerContextName name of the logger context to unregister */ public static void unregisterLoggerContext(final String loggerContextName) { if (isJmxDisabled()) { LOGGER.debug("JMX disabled for Log4j2. Not unregistering MBeans."); return; } final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); unregisterLoggerContext(loggerContextName, mbs); }
public static ThreadNameCachingStrategy create() { final String name = PropertiesUtil.getProperties().getStringProperty("AsyncLogger.ThreadNameStrategy", CACHED.name()); try { final ThreadNameCachingStrategy result = ThreadNameCachingStrategy.valueOf(name); LOGGER.debug("AsyncLogger.ThreadNameStrategy={}", result); return result; } catch (final Exception ex) { LOGGER.debug("Using AsyncLogger.ThreadNameStrategy.CACHED: '{}' not valid: {}", name, ex.toString()); return CACHED; } } }
private boolean closeConnection() { if (connection == null) { return true; } final Connection temp = connection; connection = null; try { temp.close(); return true; } catch (final JMSException e) { StatusLogger.getLogger().debug( "Caught exception closing JMS Connection: {} ({}); continuing JMS manager shutdown", e.getLocalizedMessage(), temp, e); return false; } }
private boolean closeMessageProducer() { if (messageProducer == null) { return true; } final MessageProducer temp = messageProducer; messageProducer = null; try { temp.close(); return true; } catch (final JMSException e) { StatusLogger.getLogger().debug( "Caught exception closing JMS MessageProducer: {} ({}); continuing JMS manager shutdown", e.getLocalizedMessage(), temp, e); return false; } }
private void maybeStartHelper(final Configuration config) { // If no log4j configuration was found, there are no loggers // and there is no point in starting the disruptor (which takes up // significant memory and starts a thread). if (config instanceof DefaultConfiguration) { StatusLogger.getLogger().debug("[{}] Not starting Disruptor for DefaultConfiguration.", getName()); } else { loggerDisruptor.start(); } }
private SSLContext createSslContext() { SSLContext context = null; try { context = createSslContextBasedOnConfiguration(); LOGGER.debug("Creating SSLContext with the given parameters"); } catch (final TrustStoreConfigurationException e) { context = createSslContextWithTrustStoreFailure(); } catch (final KeyStoreConfigurationException e) { context = createSslContextWithKeyStoreFailure(); } return context; }