简体   繁体   English

如何设置Atomikos不写入控制台日志?

[英]How to set Atomikos to not write to console logs?

Atomikos is quite verbose when used. Atomikos在使用时非常冗长。 There seems to be lots of INFO messages (mostly irrelevant for me) that the transaction manager writes out to the console. 事务管理器写入控制台似乎有很多INFO消息(对我来说无关紧要)。 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. transaction.properties中的设置(用于控制消息传递com.atomikos.icatch.console_log_level的级别)似乎没有任何效果,因为即使设置为WARN(或ERROR),仍会记录INFO消息。 Also the log4j settings for com.atomikos and atomikos seem to be ignored. 此外,com.atomikos和atomikos的log4j设置似乎被忽略。 Does anyone manage to turn off the INFO logs on the console with Atomikos?. 有没有人设法使用Atomikos关闭控制台上的INFO日志? How? 怎么样? Thanks 谢谢

Peter 彼得

I am using Atomikos 3.8 for testing and tried all solutions listed here (4 July 2012) and none worked. 我正在使用Atomikos 3.8进行测试,并尝试了此处列出的所有解决方案(2012年7月4日),但没有一个工作。

So I created the following class MockAtomikosLogger and called the configure method in my test set up. 所以我创建了以下类MockAtomikosLogger并在我的测试设置中调用了configure方法。

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: 我有类似的问题,并设法解决它们,如这些帖子中描述的Atomikos论坛(1),这里是解决方案的摘要:

In my classpath I have: 在我的类路径中,我有:
slf4j-api-1.6.4.jar SLF4J-API-1.6.4.jar
slf4j-log4j12-1.6.4.jar SLF4J-log4j12-1.6.4.jar
log4j-1.2.16.jar log4j的-1.2.16.jar
and I don't have other slf4j* jar files in the classpath (this is important). 我在类路径中没有其他slf4j * jar文件(这很重要)。

In my log4j.xml file I have added: 在我的log4j.xml文件中,我添加了:

<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). 请注意我使用的是“com.atomikos”而不是“atomikos”(因为后者对我不起作用)。 And now the other important trick that made the whole thing work: make sure that the property: com.atomikos.icatch.output_dir 现在,另一个重要的技巧使整个过程发挥作用:确保属性:com.atomikos.icatch.output_dir

is removed/commented out in jta.properties (or transactions.properties) 在jta.properties(或transactions.properties)中删除/注释掉

I hope it helps. 我希望它有所帮助。

(1): http://fogbugz.atomikos.com/default.asp?community.6.2809.2 (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 com.atomikos.icatch.system.Configuration . 它实际上非常简单,因为Atomikos使用集中式类来执行名为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 记录实际上是通过com.atomikos.diagnostics.Console的实现来执行的,所以我所要做的就是取消注册所有默认控制台并注册我自己的基于公共日志记录的实现

Your fix could work, but the easier thing would be to configure SLF4J/Log4J to NOT log INFO level comments for com.atomikos.* 您的修复可以正常工作,但更容易的是将SLF4J / Log4J配置为不记录com.atomikos的INFO级别注释。*

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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