简体   繁体   中英

How to set Atomikos to not write to console logs?

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 does not seem to have any effect, since even when set to WARN (or ERROR) the INFO messages are still logged. 的级别)似乎没有任何效果,因为即使设置为WARN(或ERROR),仍会记录INFO消息。 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 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

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 . 的日志记录。 Logging is actually performed with implementations of 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM