Java Code Examples for org.apache.logging.log4j.Logger#isDebugEnabled()

The following examples show how to use org.apache.logging.log4j.Logger#isDebugEnabled() . 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: MCRServletContainerInitializer.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStartup(final Set<Class<?>> c, final ServletContext ctx) throws ServletException {
    final ClassLoaderLeakPreventorFactory leakPreventorFactory = new ClassLoaderLeakPreventorFactory();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ClassLoaderLeakPreventor leakPreventor = leakPreventorFactory.newLeakPreventor(classLoader);
    leakPreventor.runPreClassLoaderInitiators();
    MCRShutdownHandler shutdownHandler = MCRShutdownHandler.getInstance();
    shutdownHandler.isWebAppRunning = true;
    shutdownHandler.leakPreventor = leakPreventor;
    MCRStartupHandler.startUp(ctx);
    //Make sure logging is configured
    final Logger logger = LogManager.getLogger();
    if (logger.isDebugEnabled()) {
        try {
            Enumeration<URL> resources = MCRClassTools.getClassLoader().getResources("META-INF/web-fragment.xml");
            while (resources.hasMoreElements()) {
                logger.debug("Found: {}", resources.nextElement());
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        logger.debug("This class is here: {}", getSource(this.getClass()));
    }
}
 
Example 2
Source File: CommandManagerMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "execute", at = @At(
        value = "INVOKE",
        target = "Lorg/apache/logging/log4j/Logger;isDebugEnabled()Z"
))
private boolean doesOutputCommandStackTrace(Logger logger)
{
    if (CarpetSettings.superSecretSetting)
        return true;
    return logger.isDebugEnabled();
}
 
Example 3
Source File: JvmGcMonitorService.java    From crate with Apache License 2.0 5 votes vote down vote up
static void logGcOverhead(
    final Logger logger,
    final JvmMonitor.Threshold threshold,
    final long current,
    final long elapsed,
    final long seq) {
    switch (threshold) {
        case WARN:
            if (logger.isWarnEnabled()) {
                logger.warn(OVERHEAD_LOG_MESSAGE, seq, TimeValue.timeValueMillis(current), TimeValue.timeValueMillis(elapsed));
            }
            break;
        case INFO:
            if (logger.isInfoEnabled()) {
                logger.info(OVERHEAD_LOG_MESSAGE, seq, TimeValue.timeValueMillis(current), TimeValue.timeValueMillis(elapsed));
            }
            break;
        case DEBUG:
            if (logger.isDebugEnabled()) {
                logger.debug(OVERHEAD_LOG_MESSAGE, seq, TimeValue.timeValueMillis(current), TimeValue.timeValueMillis(elapsed));
            }
            break;

        default:
            break;
    }
}
 
Example 4
Source File: JvmGcMonitorService.java    From crate with Apache License 2.0 4 votes vote down vote up
static void logSlowGc(
    final Logger logger,
    final JvmMonitor.Threshold threshold,
    final long seq,
    final JvmMonitor.SlowGcEvent slowGcEvent,
    BiFunction<JvmStats, JvmStats, String> pools) {

    final String name = slowGcEvent.currentGc.getName();
    final long elapsed = slowGcEvent.elapsed;
    final long totalGcCollectionCount = slowGcEvent.currentGc.getCollectionCount();
    final long currentGcCollectionCount = slowGcEvent.collectionCount;
    final TimeValue totalGcCollectionTime = slowGcEvent.currentGc.getCollectionTime();
    final TimeValue currentGcCollectionTime = slowGcEvent.collectionTime;
    final JvmStats lastJvmStats = slowGcEvent.lastJvmStats;
    final JvmStats currentJvmStats = slowGcEvent.currentJvmStats;
    final ByteSizeValue maxHeapUsed = slowGcEvent.maxHeapUsed;

    switch (threshold) {
        case WARN:
            if (logger.isWarnEnabled()) {
                logger.warn(
                    SLOW_GC_LOG_MESSAGE,
                    name,
                    seq,
                    totalGcCollectionCount,
                    currentGcCollectionTime,
                    currentGcCollectionCount,
                    TimeValue.timeValueMillis(elapsed),
                    currentGcCollectionTime,
                    totalGcCollectionTime,
                    lastJvmStats.getMem().getHeapUsed(),
                    currentJvmStats.getMem().getHeapUsed(),
                    maxHeapUsed,
                    pools.apply(lastJvmStats, currentJvmStats));
            }
            break;
        case INFO:
            if (logger.isInfoEnabled()) {
                logger.info(
                    SLOW_GC_LOG_MESSAGE,
                    name,
                    seq,
                    totalGcCollectionCount,
                    currentGcCollectionTime,
                    currentGcCollectionCount,
                    TimeValue.timeValueMillis(elapsed),
                    currentGcCollectionTime,
                    totalGcCollectionTime,
                    lastJvmStats.getMem().getHeapUsed(),
                    currentJvmStats.getMem().getHeapUsed(),
                    maxHeapUsed,
                    pools.apply(lastJvmStats, currentJvmStats));
            }
            break;
        case DEBUG:
            if (logger.isDebugEnabled()) {
                logger.debug(
                    SLOW_GC_LOG_MESSAGE,
                    name,
                    seq,
                    totalGcCollectionCount,
                    currentGcCollectionTime,
                    currentGcCollectionCount,
                    TimeValue.timeValueMillis(elapsed),
                    currentGcCollectionTime,
                    totalGcCollectionTime,
                    lastJvmStats.getMem().getHeapUsed(),
                    currentJvmStats.getMem().getHeapUsed(),
                    maxHeapUsed,
                    pools.apply(lastJvmStats, currentJvmStats));
            }
            break;

        default:
            break;
    }
}