开发者

How to set Atomikos to not write to console logs?

Atomikos is quite verbose when used. 开发者_StackOverflowThere 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


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;
    }   
}


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


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

HTH


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜