Search This Blog

Custom Logging using Log4j in BPEL Oracle BPM 11g


Custom Logging using Log4j in BPEL


Step1: Download log4j jar from apache website

http://logging.apache.org/log4j/1.2/download.html


Step 2:  Extract the zip file and use the log4j.jar file from that and put the jar file at the server so that all the applications can use it.

1. Copy the log4j.jar at the following location /Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/

2. Open the command prompt and go the above location.

3. Set the following environment variables

ANT_HOME -where your ant is installed 

ANT_HOME=D:\Oracle\oracle_Home\modules\org.apache.ant_1.7.1

PATH -path to bin folder of ant

PATH= D:\Oracle\oracle_Home\modules\org.apache.ant_1.7.1\bin

JAVA_HOME -path to jdk 

JAVA_HOME =D:\Oracle\oracle_Home\jdk160_29\bin

4. Run the ant command.  (Type ant in cmd prompt).

5. Check the oracle.soa.ext.jar file in the path log4j.jar path gets added in the jar file

6. Restart the managed server.


Step3:  checking the class path is added to the external jars.

Go to $ORACLE_HOME/soa/modules/oracle.soa.ext_11.1.1 directory.

Open the oracle.soa.ext.jar.
The Existing MANIFEST file will look like below.

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.0-b13 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle
Implementation-Title: Oracle SOA EXT
Implementation-Version: 11.1.1
Product-Name: Oracle SOA EXT
Product-Version: 11.1.1.3.0
Specification-Version: 11.1.1
Extension-Name: oracle.soa.ext
Class-Path: classes/

In my case it has added the following..

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 14.2-b01 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle
Implementation-Title: Oracle SOA EXT
Implementation-Version: 11.1.1
Product-Name: Oracle SOA EXT
Product-Version: 11.1.1.4.0
Specification-Version: 11.1.1
Extension-Name: oracle.soa.ext
Class-Path: log4j-1.2.16.jar classes/

Step4:  create a property file log4j.properties file and place the file in some location say 

D:\Oracle\prop_file

 # logging: Log4j_BPEL
log4j.category.Log4j_BPEL=info,Log4j_BPEL
log4j.appender.Log4j_BPEL=org.apache.log4j.RollingFileAppender
log4j.appender.Log4j_BPEL.File=D:\\Log4j_BPEL.log
log4j.appender.Log4j_BPEL.MaxFileSize=5MB
log4j.appender.Log4j_BPEL.MaxBackupIndex=10
log4j.appender.Log4j_BPEL.layout=org.apache.log4j.PatternLayout
log4j.appender.Log4j_BPEL.layout.ConversionPattern=%d{ISO8601} %-5p [%t] [%c] [%x] %m%n

Step5: create a BPEL process 



Step6: copy the log4j-1.2.16.jar file to SCA-INF\lib

Step7: Import the log4j-1.2.16.jar file in the project properties.

Right click project->go to project Properties->Libraries and class path->add jars.


Step8: code inside the  java Embedding.

try{
         
     String sLog4jFile = "D:\\Oracle\\prop_file\\log4j.properties";                  
     PropertyConfigurator.configure(sLog4jFile);                  
     Logger logger = Logger.getLogger("Log4j_BPEL");           
     logger.info(">>>> This is from Java Embedding: " );           
     
     XMLElement input=        
      (XMLElement)getVariableData("inputVariable","payload","/client:process/client:input");              
      addAuditTrailEntry("input is: " + input.getTextContent());             
      logger.info("Input Value :"+input.getTextContent());     
      logger.warn("hi");  
      logger.debug("Test Application");  
         
}
catch(Exception e) {        
e.printStackTrace();         
}

Step9: Import the classes in .bpel file

<bpelx:exec import="org.apache.log4j.*"/>
 <bpelx:exec import="oracle.xml.parser.v2.XMLElement"/>

Deploy the composite and check log file gets created in the location mentioned in the properties file.


Thanks to Gopinath 



2 comments:

  1. Hi,
    Please guide me on how to specify the path of property file in java embedding, if the file is in the application itself.

    ReplyDelete

  2. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle Fusion Supply Chain Management Cloud . Actually, I was looking for the same information on internet for
    Oracle Fusion HCM Interview Questions and Answers and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject.

    ReplyDelete