Hazelcast: programmatic configuration for logging in debug mode

血红的双手。 提交于 2019-12-04 03:49:02

问题


Trying to configure slf4j to log in DEBUG mode, but get only INFO logs. What am I doing wrong?

Config hazelcastConfig = new Config("HazelcastConfig");
hazelcastConfig.getProperties().put("hazelcast.logging.type", "sl4j");
hazelcastConfig.getProperties().put("slf4j.logger.com.hazelcast", "debug");
Hazelcast.newHazelcastInstance(hazelcastConfig);

回答1:


You should try

Config hazelcastConfig = new Config();
hazelcastConfig.setProperty("hazelcast.logging.type", "slf4j");
Hazelcast.newHazelcastInstance(hazelcastConfig);

Keep in mind that slf4j is just facade API for logger. You should use it with actual loggers, like log4j or logback. All required jars should be in a classapath s well. Here is a tutorial of slf4j and logback Here is an example of logback.xml.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
        </encoder>
    </appender>
    <logger name="com.hazelcast" level="DEBUG" additivity="false">
        <appender-ref ref="STDOUT"/>
    </logger>
    <root level="INFO">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

Thank you



来源:https://stackoverflow.com/questions/30391834/hazelcast-programmatic-configuration-for-logging-in-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!