4

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.

1 Answers1

5

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.

Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
  • Thanks for the reply. I tried to use slf4j-jdk14. The problem is: if I add the line `org.springframework.*=all` I see only INFO level messages in the log. – Artsiom Miklushou Oct 21 '13 at 15:33
  • 1
    Not a problem. But you need to see the other file, trace.log instead of the normal, SystemOut.log. The RAD only shows you the SystemOut.log file in the console. – Paul Vargas Oct 21 '13 at 15:52
  • 1
    I forgot to mention that you can also set the level in log4j. – Paul Vargas Oct 21 '13 at 16:31
  • Yes, I can configure levels in log4j configuration file. But I want to have possibility to change log level through WebSphere. – Artsiom Miklushou Oct 22 '13 at 06:57