use of org.neo4j.logging.Log in project neo4j by neo4j.
the class HttpHeaderUtilsTest method defaultValueWhenCustomTransactionTimeoutNotSpecified.
@Test
void defaultValueWhenCustomTransactionTimeoutNotSpecified() {
Log log = logProvider.getLog(HttpServletRequest.class);
long transactionTimeout = getTransactionTimeout(request, log);
assertEquals(0, transactionTimeout, "Transaction timeout not specified.");
assertThat(logProvider).doesNotHaveAnyLogs();
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class IndexSamplingControllerFactory method createIndexRecoveryCondition.
private RecoveryCondition createIndexRecoveryCondition(final LogProvider logProvider, final TokenNameLookup tokenNameLookup) {
return new RecoveryCondition() {
private final Log log = logProvider.getLog(IndexSamplingController.class);
@Override
public boolean test(IndexDescriptor descriptor) {
IndexSample indexSample = indexStatisticsStore.indexSample(descriptor.getId());
long samples = indexSample.sampleSize();
long size = indexSample.indexSize();
boolean empty = (samples == 0) || (size == 0);
if (empty) {
log.debug("Recovering index sampling for index %s", descriptor.schema().userDescription(tokenNameLookup));
}
return empty;
}
};
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ServerUserLogTest method logShouldRotateWhenConfigured.
@Test
void logShouldRotateWhenConfigured() throws Exception {
// given
NeoBootstrapper neoBootstrapper = getServerBootstrapper();
Path dir = homeDir.homePath();
Log logBeforeStart = neoBootstrapper.getLog();
int maxArchives = 4;
// when
try {
Map<String, String> configOverrides = stringMap(store_user_log_to_stdout.name(), FALSE, store_user_log_rotation_threshold.name(), "16", store_user_log_max_archives.name(), Integer.toString(maxArchives));
configOverrides.putAll(connectorsConfig());
int returnCode = neoBootstrapper.start(dir, configOverrides);
// then
assertEquals(OK, returnCode);
assertThat(neoBootstrapper.getLog()).isNotSameAs(logBeforeStart);
assertTrue(neoBootstrapper.isRunning());
// when we forcibly log some more stuff
do {
neoBootstrapper.getLog().info("testing 123. This string should contain more than 16 bytes\n");
Thread.sleep(2000);
} while (allUserLogFiles(dir).size() <= 4);
} finally {
// stop the server so that resources are released and test teardown isn't flaky
neoBootstrapper.stop();
}
// then no exceptions are thrown and
assertThat(getStdOut()).isEmpty();
assertTrue(Files.exists(getUserLogFileLocation(dir)));
assertThat(readUserLogFile(dir)).isNotEmpty();
List<String> userLogFiles = allUserLogFiles(dir);
assertThat(userLogFiles).contains("neo4j.log", "neo4j.log.1", "neo4j.log.2", "neo4j.log.3", "neo4j.log.4");
assertEquals(maxArchives + 1, userLogFiles.size());
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ServerUserLogTest method shouldLogToStdOutByDefault.
@Test
void shouldLogToStdOutByDefault() {
// given
NeoBootstrapper neoBootstrapper = getServerBootstrapper();
Path dir = homeDir.homePath();
Log logBeforeStart = neoBootstrapper.getLog();
// when
try {
int returnCode = neoBootstrapper.start(dir, connectorsConfig());
// then no exceptions are thrown and
assertThat(getStdOut()).isNotEmpty();
assertFalse(Files.exists(getUserLogFileLocation(dir)));
// then no exceptions are thrown and
assertEquals(OK, returnCode);
assertTrue(neoBootstrapper.isRunning());
assertThat(neoBootstrapper.getLog()).isNotSameAs(logBeforeStart);
assertThat(getStdOut()).isNotEmpty();
assertThat(getStdOut()).anyMatch(s -> s.contains("Started."));
} finally {
// stop the server so that resources are released and test teardown isn't flaky
neoBootstrapper.stop();
}
assertFalse(Files.exists(getUserLogFileLocation(dir)));
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class CommunityWebContainerBuilder method build.
public TestWebContainer build() throws IOException {
checkState(dataDir != null || !persistent, "Must specify path");
final Path configFile = createConfigFiles();
Log log = logProvider.getLog(getClass());
Config config = Config.newBuilder().setDefaults(GraphDatabaseSettings.SERVER_DEFAULTS).fromFile(configFile).build();
config.setLogger(log);
return new TestWebContainer(build(config));
}
Aggregations