简体   繁体   English

Websphere Log4j2类路径问题

[英]Websphere Log4j2 classpath issue

I'm deploying an utility jar in websphere that publishes couple of APIs. 我正在Websphere部署一个实用程序jar,该实用程序jar发布了几个API。 Now these API would be called by a webapplication. 现在,这些API将由Web应用程序调用。 Now this jar uses log4j2 for logging. 现在,此jar使用log4j2进行日志记录。 I have tried to create an uber jar by adding the packages from the two log4j2 jars ( log4j-api-2.0.2.jar && log4j-core-2.0.2.jar). 我试图通过从两个log4j2 jar(log4j-api-2.0.2.jar && log4j-core-2.0.2.jar)中添加软件包来创建uber jar。 I'm doing this by using ant to build the utility jar. 我正在通过使用ant来构建实用程序jar。

Here is the snippet of the ant code that builds up the jar for me 这是为我构建jar的ant代码片段

<!--Creates the client jar file  -->
<target name="clientjar" depends="compile">


    <jar destfile="${dist.dir}/client/myUtility.jar" basedir="${class.dir}">    

        <zipgroupfileset dir="${lib.dir}" includes="*.jar" />

        <manifest>
            <attribute name="Built-By" value="${user.name}" />
            <attribute name="Build-Date" value="${timestamp}" />
            <section name="${ant.project.name}">
                <attribute name="Implementation-Title" value="${project.implementation.title}"/>
                <attribute name="Specification-Version" value="${project.version}"/>
            </section>
        </manifest>

    </jar>
</target>

My issue is when the web application that is sitting on the same jvm invokes the jar api, log4j spits out the following error message 我的问题是,当同一jvm上的Web应用程序调用jar API时,log4j吐出以下错误消息

ERROR StatusLogger Log4j2 could not find a logging implementation. 错误StatusLogger Log4j2找不到日志记录实现。 Please add log4j-core to the classpath. 请将log4j-core添加到类路径。 Using SimpleLogger to log to the console... 使用SimpleLogger登录到控制台...

Any pointers would be helpful. 任何指针都会有所帮助。

If you unzip the log4j-core jar and re-zip it as part of a bigger jar file, make VERY sure to include ALL files that were originally in the log4j-core jar. 如果您将log4j-core jar解压缩并重新压缩为更大的jar文件的一部分,请务必确保包括原来在log4j-core jar中的所有文件。 It contains a number of config files that the log4j-api will look for. 它包含log4j-api将寻找的许多配置文件。 If these files are absent you will get the error you ran into. 如果这些文件不存在,则会出现您遇到的错误。

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

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