Search in sources :

Example 1 with Neo4jLoggerContext

use of org.neo4j.logging.log4j.Neo4jLoggerContext in project neo4j by neo4j.

the class ConfigurableStandalonePageCacheFactory method createPageCache.

/**
 * Create page cache
 * @param fileSystem file system that page cache will be based on
 * @param pageCacheTracer global page cache tracer
 * @param config page cache configuration
 * @param jobScheduler page cache job scheduler
 * @return created page cache instance
 */
public static PageCache createPageCache(FileSystemAbstraction fileSystem, PageCacheTracer pageCacheTracer, Config config, JobScheduler jobScheduler, MemoryPools memoryPools) {
    config.setIfNotSet(GraphDatabaseSettings.pagecache_memory, "8M");
    Neo4jLoggerContext loggerContext = LogConfig.createBuilder(System.err, Level.INFO).withTimezone(config.get(GraphDatabaseSettings.db_timezone)).build();
    try (Log4jLogProvider logProvider = new Log4jLogProvider(loggerContext)) {
        ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, pageCacheTracer, logProvider.getLog(PageCache.class), jobScheduler, Clocks.nanoClock(), memoryPools);
        return pageCacheFactory.getOrCreatePageCache();
    }
}
Also used : Neo4jLoggerContext(org.neo4j.logging.log4j.Neo4jLoggerContext) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) PageCache(org.neo4j.io.pagecache.PageCache)

Example 2 with Neo4jLoggerContext

use of org.neo4j.logging.log4j.Neo4jLoggerContext in project neo4j by neo4j.

the class NeoBootstrapper method setupLogging.

private static Log4jLogProvider setupLogging(Config config) {
    LogConfig.Builder builder = LogConfig.createBuilder(new DefaultFileSystemAbstraction(), config.get(GraphDatabaseSettings.store_user_log_path), config.get(GraphDatabaseSettings.store_internal_log_level)).withTimezone(config.get(GraphDatabaseSettings.db_timezone)).withFormat(config.get(GraphDatabaseSettings.store_user_log_format)).withCategory(false).withRotation(config.get(GraphDatabaseSettings.store_user_log_rotation_threshold), config.get(GraphDatabaseSettings.store_user_log_max_archives));
    if (config.get(GraphDatabaseSettings.store_user_log_to_stdout)) {
        builder.logToSystemOut();
    }
    Neo4jLoggerContext ctx = builder.build();
    Log4jLogProvider userLogProvider = new Log4jLogProvider(ctx);
    JULBridge.resetJUL();
    Logger.getLogger("").setLevel(Level.WARNING);
    JULBridge.forwardTo(userLogProvider);
    JettyLogBridge.setLogProvider(userLogProvider);
    return userLogProvider;
}
Also used : Neo4jLoggerContext(org.neo4j.logging.log4j.Neo4jLoggerContext) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) LogConfig(org.neo4j.logging.log4j.LogConfig)

Example 3 with Neo4jLoggerContext

use of org.neo4j.logging.log4j.Neo4jLoggerContext in project neo4j by neo4j.

the class GlobalModule method createLogService.

protected LogService createLogService(LogProvider userLogProvider) {
    // Will get diagnostics as header in each newly created log file (diagnostics in the first file is printed during start up).
    Neo4jLoggerContext loggerContext = LogConfig.createBuilder(fileSystem, globalConfig.get(store_internal_log_path), globalConfig.get(store_internal_log_level)).withFormat(globalConfig.get(store_internal_log_format)).withTimezone(globalConfig.get(db_timezone)).withHeaderLogger(log -> dbmsDiagnosticsManager.dumpAll(log), DiagnosticsManager.class.getCanonicalName()).withRotation(globalConfig.get(store_internal_log_rotation_threshold), globalConfig.get(store_internal_log_max_archives)).build();
    Log4jLogProvider internalLogProvider = new Log4jLogProvider(loggerContext);
    userLogProvider = userLogProvider == null ? NullLogProvider.getInstance() : userLogProvider;
    SimpleLogService logService = new SimpleLogService(userLogProvider, internalLogProvider);
    // Listen to changes to the dynamic log level settings.
    globalConfig.addListener(store_internal_log_level, (before, after) -> internalLogProvider.updateLogLevel(after));
    // If the user log provider comes from us we make sure that it starts with the default log level and listens to updates.
    if (userLogProvider instanceof Log4jLogProvider) {
        Log4jLogProvider provider = (Log4jLogProvider) userLogProvider;
        provider.updateLogLevel(globalConfig.get(store_internal_log_level));
        globalConfig.addListener(store_internal_log_level, (before, after) -> provider.updateLogLevel(after));
    }
    return globalLife.add(logService);
}
Also used : Neo4jLoggerContext(org.neo4j.logging.log4j.Neo4jLoggerContext) DiagnosticsManager(org.neo4j.internal.diagnostics.DiagnosticsManager) DbmsDiagnosticsManager(org.neo4j.kernel.diagnostics.providers.DbmsDiagnosticsManager) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider)

Example 4 with Neo4jLoggerContext

use of org.neo4j.logging.log4j.Neo4jLoggerContext in project neo4j by neo4j.

the class AbstractInProcessNeo4jBuilder method build.

@Override
public InProcessNeo4j build() {
    Path userLogFile = serverFolder.resolve("neo4j.log");
    Path internalLogFile = serverFolder.resolve("debug.log");
    config.set(ServerSettings.third_party_packages, unmanagedExtentions.toList());
    config.set(GraphDatabaseSettings.store_internal_log_path, internalLogFile.toAbsolutePath());
    var certificates = serverFolder.resolve("certificates");
    if (disabledServer) {
        config.set(HttpConnector.enabled, false);
        config.set(HttpsConnector.enabled, false);
    }
    Config dbConfig = config.build();
    if (dbConfig.get(HttpsConnector.enabled) || dbConfig.get(BoltConnector.enabled) && dbConfig.get(BoltConnector.encryption_level) != BoltConnector.EncryptionLevel.DISABLED) {
        SelfSignedCertificateFactory.create(certificates);
        List<SslPolicyConfig> policies = List.of(SslPolicyConfig.forScope(HTTPS), SslPolicyConfig.forScope(BOLT));
        for (SslPolicyConfig policy : policies) {
            config.set(policy.enabled, Boolean.TRUE);
            config.set(policy.base_directory, certificates);
            config.set(policy.trust_all, true);
            config.set(policy.client_auth, ClientAuth.NONE);
        }
        dbConfig = config.build();
    }
    Neo4jLoggerContext loggerContext = LogConfig.createBuilder(new DefaultFileSystemAbstraction(), userLogFile, Level.INFO).withTimezone(dbConfig.get(db_timezone)).build();
    var userLogProvider = new Log4jLogProvider(loggerContext);
    GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider);
    dependencies = dependencies.extensions(buildExtensionList(dependencies));
    var managementService = createNeo(dbConfig, dependencies);
    InProcessNeo4j controls = new InProcessNeo4j(serverFolder, userLogFile, internalLogFile, managementService, dbConfig, userLogProvider);
    controls.start();
    try {
        fixtures.applyTo(controls);
    } catch (Exception e) {
        controls.close();
        throw e;
    }
    return controls;
}
Also used : Path(java.nio.file.Path) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) Neo4jLoggerContext(org.neo4j.logging.log4j.Neo4jLoggerContext) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) Config(org.neo4j.configuration.Config) LogConfig(org.neo4j.logging.log4j.LogConfig) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) GraphDatabaseDependencies(org.neo4j.graphdb.facade.GraphDatabaseDependencies) IOException(java.io.IOException)

Aggregations

Log4jLogProvider (org.neo4j.logging.log4j.Log4jLogProvider)4 Neo4jLoggerContext (org.neo4j.logging.log4j.Neo4jLoggerContext)4 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 LogConfig (org.neo4j.logging.log4j.LogConfig)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Config (org.neo4j.configuration.Config)1 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)1 GraphDatabaseDependencies (org.neo4j.graphdb.facade.GraphDatabaseDependencies)1 DiagnosticsManager (org.neo4j.internal.diagnostics.DiagnosticsManager)1 PageCache (org.neo4j.io.pagecache.PageCache)1 DbmsDiagnosticsManager (org.neo4j.kernel.diagnostics.providers.DbmsDiagnosticsManager)1 SimpleLogService (org.neo4j.logging.internal.SimpleLogService)1