开发者

How to remove/hide Atomikos startup error message?

开发者 https://www.devze.com 2023-01-02 20:42 出处:网络
When Atomikos is configured via Spring, a jta.properties or transactions.properties file is not needed.Nonetheless, Atomikos starts up with the follow messages printed to stderr:

When Atomikos is configured via Spring, a jta.properties or transactions.properties file is not needed. Nonetheless, Atomikos starts up with the follow messages printed to stderr:

No properties path set - looking for transactions.properties in classpath...
transactions.properties not found - looking for jta.properties in classpath...
Failed to open transactions properties file - using default values

It makes it look like the Spring configuration didn't take -- although apparently everything is fine. Does anyone know how to get rid of this so I don't end up getting asked a开发者_运维百科bout it 1.000 times?

Is there a way to redirect stderr from a particular component or jar?


You need to set the system property com.atomikos.icatch.hide_init_file_path to any value. Do this on the java command line. In maven you do this by passing a command line arg to surefire as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>-Dcom.atomikos.icatch.hide_init_file_path=true</argLine>
    </configuration>
</plugin>

Update: From within a Spring configuration file, you can set the property like this:

<bean id="atomikosSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject">
        <!-- System.getProperties() -->
        <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
            <property name="targetClass" value="java.lang.System" />
            <property name="targetMethod" value="getProperties" />
        </bean>
    </property>
    <property name="targetMethod" value="putAll" />
    <property name="arguments">
        <!-- The new Properties -->
        <util:properties>
            <prop key="com.atomikos.icatch.hide_init_file_path">true</prop>
        </util:properties>
    </property>
</bean>

Just remember to make your Atomikos beans "depend-on" this bean so the order of instantiation is correct.


Atomikos logs with SLF4J. If only this dependency logs with SLF4J, you can use SLF4J's NOP binder and nothing will be logged. Probably not what you want, but very simple.

You can configure your SLF4J's backend logger to ignore log messages in specific packages. An example with logback as SLF4J' backend logger:

<logger name="com.atomikos.something" level="OFF"/>

I have written a tutorial about SLF4J and different backend loggers here.

0

精彩评论

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