This discussion is archived
5 Replies Latest reply: Aug 8, 2012 6:12 AM by mjmjava RSS

server not getting log4j.jar placed in domain roots/lib folder

mjmjava Newbie
Currently Being Moderated
Hello

I am using oracle Weblogic server 11g Release 1(11.1.1.6) and at the time of implementing Log4j i am facing error, i have followed these steps



1. Copy wllog4j.jar from your WebLogic server/lib directory and place it in your domain_root/lib folder.
2. Copy your version of log4j.jar to your domain_root/lib folder.
3. Copy your log4j.xml to your domain_root folder.
4. Log in to the your WebLogic admin server console. Click on Servers -> Admin Server -> Logging. Click on advanced mode, and change the logging implementation from JDK to Log4J. Save your changes.

Most of the blogs had these items, but the one critical piece that was missing:
5. (Linux)Edit the setDomainEnv.sh file in the domain_root/bin directory. and find the following code:


if [ "${LOG4J_CONFIG_FILE}" != "" ] ; then
JAVA_PROPERTIES="${JAVA_PROPERTIES} -Dlog4j.configuration=file:${LOG4J_CONFIG_FILE}"
export JAVA_PROPERTIES
fi


Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:


LOG4J_CONFIG_FILE=”/u01/app/oracle/middleware/user_projects/domains/base_domain/log4j.xml”
Export LOG4J_CONFIG_FILE


5. (Windows)
Edit the setDomainEnv.cmd file in the domain_root/bin directory. and find the following code:


if NOT "%LOG4J_CONFIG_FILE%"=="" (
set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)


Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:


set LOG4J_CONFIG_FILE=%DOMAIN_HOME%/log4j.xml



6. Activate the changes and restart the admin server.

Here is a sample log4j.xml file. Obviously, you will need to update it for a valid location for your file appender, and replace yourcompany and yourproject with valid values.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!--====================================================================-->
<!-- Appenders -->
<!-- %d{dd-MMM-yy HH:mm:ss} %-5p [%c{1}] %m%n -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p] - %m (%F:%M:%L)%n"/>
<!--param name="ConversionPattern" value="%d{ISO8601} %p [%c{1}] - %m (%F:%M:%L)%n"/-->
</layout>
</appender>

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="/temp/logs/yourproject.log"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %t %-5p %c{2} - %m%n"/>
</layout>
</appender>

<!--====================================================================-->
<!-- Logging Levels -->

<category name="com.yourcompany.yourproject">
<priority value="DEBUG"/>
</category>

<category name="org.apache">
<priority value="WARN"/>
</category>

<category name="org.springframework">
<priority value="WARN"/>
</category>

<!--===================================================================-->
<!-- Appender Assignments -->
<root>
<priority value="ERROR"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>







The weblogic server not getting log4j.jar its throwing following error



[6:57:44 PM] Girish A Patil: <Aug 7, 2012 6:56:02 PM IST> <Critical> <WebLogicServer> <BEA-000386> <Server su
bsystem failed. Reason: java.lang.NoSuchMethodError: com.bea.logging.LogBufferHa
ndler.getServerLogBufferHandler()Lcom/bea/logging/LogBufferHandler;
java.lang.NoSuchMethodError: com.bea.logging.LogBufferHandler.getServerLogBuffer
Handler()Lcom/bea/logging/LogBufferHandler;
at weblogic.logging.log4j.JDKLog4jAdapterFactory.createAndInitializeServ
erLogger(JDKLog4jAdapterFactory.java:82)
at weblogic.logging.ServerLoggingInitializer.initializeServerLogging(Ser
verLoggingInitializer.java:50)
at weblogic.diagnostics.lifecycle.ServerLoggingLifecycleImpl.initialize(
ServerLoggingLifecycleImpl.java:43)
at weblogic.diagnostics.lifecycle.DiagnosticFoundationService.start(Diag
nosticFoundationService.java:108)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
Truncated. see log file for complete stacktrace
>
***************************************************************************
The WebLogic Server encountered a critical failure
Reason: Assertion violated
***************************************************************************
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize
class weblogic.protocol.ServerIdentityManager$Initializer
at weblogic.protocol.ServerIdentityManager.findServerIdentity(ServerIden
tityManager.java:64)
at weblogic.protocol.URLManager.findAdministrationURL(URLManager.java:17
3)
at weblogic.server.ServerLifeCycleRuntime.getLifeCycleOperationsRemote(S
erverLifeCycleRuntime.java:1078)
at weblogic.t3.srvr.ServerRuntime.sendStateToAdminServer(ServerRuntime.j
ava:429)
at weblogic.t3.srvr.ServerRuntime.updateRunState(ServerRuntime.java:415)

at weblogic.t3.srvr.T3Srvr.setState(T3Srvr.java:206)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:482)
at weblogic.Server.main(Server.java:71)



how to give server the address of log4j.jar in setDomainEnv.cmd please specify

Regards
Mayur Mitkari
  • 1. Re: server not getting log4j.jar placed in domain roots/lib folder
    RenévanWijk Oracle ACE
    Currently Being Moderated
    When you restart the server, can you check the classpath, to see if it contains your log4j jars.

    If not, you can also edit the commEnv file, located in the $WL_HOME/common/bin directory.
    The commEnv file contains a variable called WEBLOGIC_CLASSPATH, i.e.,
    # set up WebLogic Server's class path 
    WEBLOGIC_CLASSPATH="${JAVA_HOME}/lib/tools.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.jar${CLASSPATHSEP}${FEATURES_DIR}/weblogic.server.modules_12.1.1.0.jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.jar${CLASSPATHSEP}${ANT_HOME}/lib/ant-all.jar${CLASSPATHSEP}${ANT_CONTRIB}/lib/ant-contrib.jar"
    export WEBLOGIC_CLASSPATH
    You can append you jar to this line, for example,
    WEBLOGIC_CLASSPATH=${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}some/directory/log4j.jar
  • 2. Re: server not getting log4j.jar placed in domain roots/lib folder
    mjmjava Newbie
    Currently Being Moderated
    Hello Sir,


    I am not able to find this line in my commEnv file instead i have following code containing WEBLOGIC_CLASSPATH

    if NOT "%WEBLOGIC_CLASSPATH%"=="" (
         if NOT "%CLASSPATH%"=="" (
              set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%
         ) else (
              set CLASSPATH=%WEBLOGIC_CLASSPATH%;
         )
    )

    if NOT "%PRE_CLASSPATH%"=="" (
         set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
    )

    if NOT "%JAVA_VENDOR%"=="BEA" (
         set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
    ) else (
         set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
    )


    so where i can specify the path of log4j.jar in this code , my log4j.jar is present in DOMAIN HOME/lib folder
    please give me exact code




    Regards

    Mayur Mitkari
  • 3. Re: server not getting log4j.jar placed in domain roots/lib folder
    RenévanWijk Oracle ACE
    Currently Being Moderated
    You are in the wrong file, i.e., setDomainEnv (located in the ${DOMAIN_HOME}/bin directory).

    You must search in the commEnv file - located in the ${WL_HOME}/common/bin directory.

    Also note that the example above is for Linux and you are on Windows. On Windows you have to use something like:

    set WEBLOGIC_CLASSPATH=%WEBLOGIC_CLASSPATH%;DIRECTORY_WHERE_YOU_PLACED_YOUR_JARS\log4j.jar
  • 4. Re: server not getting log4j.jar placed in domain roots/lib folder
    mjmjava Newbie
    Currently Being Moderated
    Sir,


    I am windows user so does i need to type this line

    set WEBLOGIC_CLASSPATH=%WEBLOGIC_CLASSPATH%;DIRECTORY_WHERE_YOU_PLACED_YOUR_JARS\log4j.jar


    in

    ${WL_HOME}/common/bin directory.


    folder please specify

    Regards
    Mayur Mitkari
  • 5. Re: server not getting log4j.jar placed in domain roots/lib folder
    mjmjava Newbie
    Currently Being Moderated
    Thanks Sir,
    It worked for me

    Regards
    Mayur Mitkari

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points