1

我有一个在 WAS 6.1 上运行的 Java 应用程序,Log4j 用于日志记录。不创建日志文件。使用了其他一些日志配置,但不是与应用程序一起打包的配置。

我应该在哪里检查 WAS6.1 全局 log4j 配置?如何为特定应用程序覆盖它?

该应用程序是从战争档案中部署的。
log4j-1.2.14.jar 与应用程序一起打包在 WEB-INF/lib 目录下。我在 WEB-INF 目录中放置了一个 commons-logging.properties 文件。

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    id="WebApp_ID" version="2.4">
    <display-name>LineCheckOptimizerWeb</display-name>
    <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.xml</param-value>
</context-param>

<listener>
    <description>Initializes a Guice Injector and installs it into the ServletContext</description>
    <display-name>GuiceInitializer</display-name>
    <listener-class>com.aa.otrs.lco.guice.GuiceInitializer</listener-class>
</listener>

    <servlet>
            <servlet-name>MessageBrokerServlet</servlet-name>
            <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
            <init-param>
                    <param-name>services.configuration.file</param-name>
                    <param-value>/WEB-INF/flex/services-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
            <servlet-name>MessageBrokerServlet</servlet-name>
            <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>

    <resource-ref>
            <description>LCO JDBC Datasource</description>
            <res-ref-name>jdbc/lco</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>

4

3 回答 3

2

Check if any other jar file is present in your application which also includes a log4j.xml. Conflict will not allow proper logging to be enabled. Also enable trace with trace string com.ibm.ws.classloader.*=all and restart the server. Check trace.log

I faced similar issue recently where the team added external jars

于 2012-08-15T06:53:22.667 回答
0

I would turn on the debugger for log4j (via the System D property) and see what is the log4j properties that is picked and if it picks up the one that you expect it to. This is the first thing to do when you encounter log4j config issues.

If you are using JCL , WAS 6.1 has moved away from JCL and uses JUL (saying this from memory) Have a look at this -> http://www.ibm.com/developerworks/websphere/techjournal/0901_supauth/0901_supauth.html and see if that helps.

于 2012-08-16T01:41:23.103 回答
0

Turns out it was missing a log4j jar inside one of the project *.jar-s that had the logging inside it. Fixed it, and viola - it worked, log files magically appeared as expected.

于 2012-08-16T18:54:30.243 回答