Search in sources :

Example 1 with Logger

use of org.apache.logging.log4j.Logger in project elasticsearch by elastic.

the class LoggingListener method reset.

/**
     * Reset the logging levels to the state provided by the map.
     *
     * @param map the logging levels to apply
     * @return an empty map
     */
private Map<String, String> reset(final Map<String, String> map) {
    for (final Map.Entry<String, String> previousLogger : map.entrySet()) {
        final Logger logger = resolveLogger(previousLogger.getKey());
        Loggers.setLevel(logger, previousLogger.getValue());
    }
    return Collections.emptyMap();
}
Also used : Logger(org.apache.logging.log4j.Logger) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with Logger

use of org.apache.logging.log4j.Logger in project elasticsearch by elastic.

the class Node method stop.

private Node stop() {
    if (!lifecycle.moveToStopped()) {
        return this;
    }
    Logger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(settings));
    logger.info("stopping ...");
    injector.getInstance(TribeService.class).stop();
    injector.getInstance(ResourceWatcherService.class).stop();
    if (NetworkModule.HTTP_ENABLED.get(settings)) {
        injector.getInstance(HttpServerTransport.class).stop();
    }
    injector.getInstance(SnapshotsService.class).stop();
    injector.getInstance(SnapshotShardsService.class).stop();
    // stop any changes happening as a result of cluster state changes
    injector.getInstance(IndicesClusterStateService.class).stop();
    // close discovery early to not react to pings anymore.
    // This can confuse other nodes and delay things - mostly if we're the master and we're running tests.
    injector.getInstance(Discovery.class).stop();
    // we close indices first, so operations won't be allowed on it
    injector.getInstance(RoutingService.class).stop();
    injector.getInstance(ClusterService.class).stop();
    injector.getInstance(NodeConnectionsService.class).stop();
    injector.getInstance(MonitorService.class).stop();
    injector.getInstance(GatewayService.class).stop();
    injector.getInstance(SearchService.class).stop();
    injector.getInstance(TransportService.class).stop();
    injector.getInstance(SearchTransportService.class).stop();
    pluginLifecycleComponents.forEach(LifecycleComponent::stop);
    // we should stop this last since it waits for resources to get released
    // if we had scroll searchers etc or recovery going on we wait for to finish.
    injector.getInstance(IndicesService.class).stop();
    logger.info("stopped");
    return this;
}
Also used : TribeService(org.elasticsearch.tribe.TribeService) SnapshotsService(org.elasticsearch.snapshots.SnapshotsService) SnapshotShardsService(org.elasticsearch.snapshots.SnapshotShardsService) NodeConnectionsService(org.elasticsearch.cluster.NodeConnectionsService) MonitorService(org.elasticsearch.monitor.MonitorService) RoutingService(org.elasticsearch.cluster.routing.RoutingService) Discovery(org.elasticsearch.discovery.Discovery) IndicesService(org.elasticsearch.indices.IndicesService) Logger(org.apache.logging.log4j.Logger) DeprecationLogger(org.elasticsearch.common.logging.DeprecationLogger) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) GatewayService(org.elasticsearch.gateway.GatewayService) IndicesClusterStateService(org.elasticsearch.indices.cluster.IndicesClusterStateService) ClusterService(org.elasticsearch.cluster.service.ClusterService) SearchTransportService(org.elasticsearch.action.search.SearchTransportService) TransportService(org.elasticsearch.transport.TransportService) LifecycleComponent(org.elasticsearch.common.component.LifecycleComponent) SearchService(org.elasticsearch.search.SearchService) SearchTransportService(org.elasticsearch.action.search.SearchTransportService) ResourceWatcherService(org.elasticsearch.watcher.ResourceWatcherService)

Example 3 with Logger

use of org.apache.logging.log4j.Logger in project elasticsearch by elastic.

the class Bootstrap method checkUnsetAndMaybeExit.

private static void checkUnsetAndMaybeExit(String confFileSetting, String settingName) {
    if (confFileSetting != null && confFileSetting.isEmpty() == false) {
        Logger logger = Loggers.getLogger(Bootstrap.class);
        logger.info("{} is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed.", settingName);
        exit(1);
    }
}
Also used : Logger(org.apache.logging.log4j.Logger)

Example 4 with Logger

use of org.apache.logging.log4j.Logger in project elasticsearch by elastic.

the class ElasticsearchUncaughtExceptionHandler method onFatalUncaught.

// visible for testing
void onFatalUncaught(final String threadName, final Throwable t) {
    final Logger logger = Loggers.getLogger(ElasticsearchUncaughtExceptionHandler.class, loggingPrefixSupplier.get());
    logger.error((org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage("fatal error in thread [{}], exiting", threadName), t);
}
Also used : ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) Logger(org.apache.logging.log4j.Logger)

Example 5 with Logger

use of org.apache.logging.log4j.Logger in project elasticsearch by elastic.

the class JarHell method checkJarHell.

/**
     * Checks the current classpath for duplicate classes
     * @throws IllegalStateException if jar hell was found
     */
public static void checkJarHell() throws IOException, URISyntaxException {
    ClassLoader loader = JarHell.class.getClassLoader();
    Logger logger = Loggers.getLogger(JarHell.class);
    if (logger.isDebugEnabled()) {
        logger.debug("java.class.path: {}", System.getProperty("java.class.path"));
        logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path"));
        if (loader instanceof URLClassLoader) {
            logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader) loader).getURLs()));
        }
    }
    checkJarHell(parseClassPath());
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Logger(org.apache.logging.log4j.Logger)

Aggregations

Logger (org.apache.logging.log4j.Logger)489 Test (org.junit.Test)225 File (java.io.File)80 Test (org.junit.jupiter.api.Test)69 IOException (java.io.IOException)34 Appender (org.apache.logging.log4j.core.Appender)32 LoggerContext (org.apache.logging.log4j.core.LoggerContext)31 Collectors (java.util.stream.Collectors)30 StatusLogger (org.apache.logging.log4j.status.StatusLogger)30 BufferedReader (java.io.BufferedReader)29 FileReader (java.io.FileReader)26 Path (java.nio.file.Path)26 Level (org.apache.logging.log4j.Level)26 CountDownLatch (java.util.concurrent.CountDownLatch)23 Map (java.util.Map)21 IntStream (java.util.stream.IntStream)20 LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)20 java.util (java.util)18 HashMap (java.util.HashMap)18 Configuration (org.apache.logging.log4j.core.config.Configuration)18