use of com.hazelcast.logging.Log4j2Factory in project hazelcast by hazelcast.
the class ClientLoggerConfigurationTest method testLoggingWithConfiguration.
// Test with programmatic or system property configuration according to boolean parameter.
// the idea of the test is to configure a specific logging type for a client and then
// test its LoggingService produce instances of the expected Logger impl
protected void testLoggingWithConfiguration(boolean programmaticConfiguration) throws IOException {
hazelcastFactory = new TestHazelcastFactory();
Config cg = new Config();
cg.setProperty("hazelcast.logging.type", "jdk");
hazelcastFactory.newHazelcastInstance(cg);
ClientConfig config = new ClientConfig();
if (programmaticConfiguration) {
config.setProperty("hazelcast.logging.type", "log4j2");
} else {
System.setProperty("hazelcast.logging.type", "log4j2");
}
client = hazelcastFactory.newHazelcastClient(config);
ILogger clientLogger = client.getLoggingService().getLogger("loggerName");
// this part is fragile.
// client wraps the actual logger in its own class
ILogger actualLogger = (ILogger) getFromField(clientLogger, "logger");
Class<?> clientLoggerClass = actualLogger.getClass();
ILogger expectedLogger = new Log4j2Factory().getLogger("expectedLogger");
Class<?> expectedLoggerClass = expectedLogger.getClass();
assertSame(expectedLoggerClass, clientLoggerClass);
}
Aggregations