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();
}
}
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;
}
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);
}
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;
}
Aggregations