Question

Is it possible to configure logging level at runtime on WebSphere 7 Application Server through the «Logging and tracing» menu?

I use slf4j-log4j12 and jcl-over-slf4j.

For ex. I have following log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//LOGGER" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p: %c - %m%n" />
    </layout>
</appender>

<!-- Root Logger -->
<root>
    <priority value="TRACE" />
    <appender-ref ref="console" />
</root>
</log4j:configuration>

That log4j configuration prints a lot of debug and trace information into SystemOut.log file. Like:

[10/21/13 16:31:18:141 FET] 0000001a SystemOut O DEBUG: org.springframework.core.convert.support.GenericConversionService - Converted to '10/21/14' [10/21/13 16:31:18:141 FET] 0000001a SystemOut O TRACE: org.springframework.core.convert.support.GenericConversionService - Checking if I can convert java.lang.String to @org.springframework.format.annotation.DateTimeFormat @javax.validation.constraints.Future java.util.Date

So, I tried to add the line:

org.springframework.*=info

But, it didn't affect log level of my web application.

Was it helpful?

Solution

Setting the level in log4j

Since you are using log4j as logging framework, you can't configure the level using Logging and Tracing option.

The level should be configured in the log4j configuration file. e.g.:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <!-- console -->
    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
        <param name="threshold" value="TRACE" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="conversionPattern"
                value="%-5p (%c.java:%L).%M - %m%n" />
        </layout>
    </appender>

    <!-- categories -->
    <category name="org.hibernate">
        <priority value="OFF" />
    </category>
    <category name="org.hibernate.type">
        <priority value="ALL" />
    </category>
    <category name="org.springframework">
        <priority value="INFO" />
    </category>


    <!-- root -->
    <root>
        <priority value="TRACE" />
        <appender-ref ref="STDOUT" />
    </root>
</log4j:configuration>


Using the default implementation (JUL)

In another way, java.util.logging (JUL) is the preferred logging implementation in WebSphere Application Server, and is used in WebSphere Application Server's own implementation.

So, you could try the following configuration of SLF4J if you want use the WAS logging infrastructure:

enter image description here

See more in The Support Authority: A developer's guide to WebSphere Application Server logging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top