简体   繁体   English

运行时的WebSphere 7日志级别配置

[英]WebSphere 7 log level configuration at runtime

Is it possible to configure logging level at runtime on WebSphere 7 Application Server through the «Logging and tracing» menu? 是否可以通过«Logging and tracing»菜单在WebSphere 7 Application Server上的运行时配置日志记录级别?

I use slf4j-log4j12 and jcl-over-slf4j. 我使用slf4j-log4j12和jcl-over-slf4j。

For ex. 对于前者 I have following log4j.xml 我有以下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. log4j配置将大量调试和跟踪信息输出到SystemOut.log文件中。 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 [10/21/13 16:31:18:141 FET] 0000001a SystemOut O DEBUG:org.springframework.core.convert.support.GenericConversionService - 转换为'10 / 21/14'[10/21/13 16:31 :18:141 FET] 0000001a SystemOut O TRACE:org.springframework.core.convert.support.GenericConversionService - 检查我是否可以将java.lang.String转换为@ 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. 但是,它不会影响我的Web应用程序的日志级别。

Setting the level in log4j 在log4j中设置级别

Since you are using log4j as logging framework, you can't configure the level using Logging and Tracing option. 由于您使用log4j作为日志记录框架,因此无法使用“ 日志记录和跟踪”选项配置级别。

The level should be configured in the log4j configuration file. 应在log4j配置文件中配置级别。 eg: 例如:

<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) 使用默认实现(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. 换句话说, java.util.logging (JUL)是WebSphere Application Server中首选的日志记录实现,并在WebSphere Application Server自己的实现中使用。

So, you could try the following configuration of SLF4J if you want use the WAS logging infrastructure: 因此,如果要使用WAS日志记录基础结构,可以尝试以下SLF4J配置:

在此输入图像描述

See more in The Support Authority: A developer's guide to WebSphere Application Server logging . 有关详细信息,请参阅支持机构:WebSphere Application Server日志记录的开发人员指南

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

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