How to set Atomikos to not write to console logs?

 ̄綄美尐妖づ 提交于 2019-12-10 19:13:53

问题


Atomikos is quite verbose when used. There seems to be lots of INFO messages (mostly irrelevant for me) that the transaction manager writes out to the console. The setting in the transaction.properties that is suppose to control the level of messaging com.atomikos.icatch.console_log_level does not seem to have any effect, since even when set to WARN (or ERROR) the INFO messages are still logged. Also the log4j settings for com.atomikos and atomikos seem to be ignored. Does anyone manage to turn off the INFO logs on the console with Atomikos?. How? Thanks

Peter


回答1:


I am using Atomikos 3.8 for testing and tried all solutions listed here (4 July 2012) and none worked.

So I created the following class MockAtomikosLogger and called the configure method in my test set up.

Test Setup code fragment:

    MockAtomikosLogger.configure();

The mock logger follows:

package com.atomikos.logging;

import com.atomikos.logging.Logger;

public class MockAtomikosLogger implements Logger {

    org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(getClass());

    public static void configure() {
        com.atomikos.logging.LoggerFactory.setLoggerFactoryDelegate(
                new LoggerFactoryDelegate() {

                    @Override
                    public Logger createLogger(Class<?> clazz) {
                        return new MockAtomikosLogger();
                    }
                });
    }//end configure

    @Override
    public void logWarning(String message) {
        logger.warn(message);
    }

    @Override
    public void logInfo(String message) {
    }

    @Override
    public void logDebug(String message) {
    }

    @Override
    public void logWarning(String message, Throwable error) {
        logger.warn(message, error);
    }

    @Override
    public void logInfo(String message, Throwable error) {
    }

    @Override
    public void logDebug(String message, Throwable error) {
    }

    @Override
    public boolean isDebugEnabled() {
        return false;
    }

    @Override
    public boolean isInfoEnabled() {
        return false;
    }   
}



回答2:


I've figured out a way to do that. It is actually very simple since Atomikos uses a centralize class to do the logging called com.atomikos.icatch.system.Configuration. Logging is actually performed with implementations of com.atomikos.diagnostics.Console so all I had to do is to un-register all default consoles and register my own implementation that's based on commons logging




回答3:


Your fix could work, but the easier thing would be to configure SLF4J/Log4J to NOT log INFO level comments for com.atomikos.*

HTH




回答4:


I had similar issues and managed to resolve them as described in these posts to the Atomikos forum (1), here is a summary of the solution:

In my classpath I have:
slf4j-api-1.6.4.jar
slf4j-log4j12-1.6.4.jar
log4j-1.2.16.jar
and I don't have other slf4j* jar files in the classpath (this is important).

In my log4j.xml file I have added:

<logger name="com.atomikos">
    <level value="error" />
</logger>

Please notice that I used "com.atomikos" and not "atomikos" (as the latter doesn't work for me). And now the other important trick that made the whole thing work: make sure that the property: com.atomikos.icatch.output_dir

is removed/commented out in jta.properties (or transactions.properties)

I hope it helps.

(1): http://fogbugz.atomikos.com/default.asp?community.6.2809.2



来源:https://stackoverflow.com/questions/2667851/how-to-set-atomikos-to-not-write-to-console-logs

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