In this recipe, we will discuss the configuration of the logfiles. The configuration of the logfiles is important because it enables us to fine-tune the information we want to gather from the BPEL process execution.
For this recipe, there is no special preparation needed. However, further discussion will lead us to more specific configuration of the logfiles. For that purpose, we will use the BPEL process that we prepared for this chapter. The BPEL process first checks the hotel availability, receives the room price, and checks for car availability.
By following the next steps, we will configure logfiles through the Oracle Enterprise Manager Console:
Now we have defined the logger file in order to separate logging for our custom logger defined in the Creating a custom logger in a BPEL process recipe.
Oracle SOA Suite has its logging configuration managed through the Oracle Enterprise Manager Console. There exist the following four predefined logfiles for the Oracle SOA Suite components:
em-log-handler
(logs the enterprise manager data)em-trc-handler
(logs the enterprise manager data)odl-handler
(logs the general diagnostic data)owsm-message-handler
(logs diagnostic data for the Oracle Web Service Manager)In a BPEL process, there is also a possibility to configure the logfiles autonomously from the Oracle SOA Suite. We will utilize the sample BPEL process we prepared in previous recipes with the LOG4J logging utility. Our task is to make every BPEL process instance log into its own logfile. The format of the logfile name is log_BPEL_<instance_id>.log
:
SCA-INF/lib
directory.<domain_home>
. The content of the LOG4J properties file we defined is as shown in the following code:log4j.rootLogger=debug, stdout, BPEL log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n log4j.appender.BPEL=org.apache.log4j.RollingFileAppender log4j.appender.BPEL.File=example.log log4j.appender.BPEL.MaxFileSize=100KB log4j.appender.BPEL.MaxBackupIndex=5 log4j.appender.BPEL.layout=org.apache.log4j.PatternLayout log4j.appender.BPEL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
That's it! We prepared the infrastructure to utilize the custom logfile defined outside of the Oracle SOA Suite framework.
We will now create the Logger
class which will use the infrastructure we just prepared:
LogDynamic
. In the static section, we set the properties file for logging and extract FileAppender
from the logging configuration as shown in the following code:static { String sLog4jFile = "C:\Programs\Oracle\Middleware\user_projects\domains\SOA_Dev\dyna_log4j.properties"; PropertyConfigurator.configure(sLog4jFile); Logger rootLogger= Logger.getRootLogger(); Enumeration appenders = rootLogger.getAllAppenders(); while(appenders.hasMoreElements()) { Appender currAppender = (Appender) appenders.nextElement(); if(currAppender instanceof FileAppender) { fa = (FileAppender) currAppender; } } }
if (fa!= null) { if(fa.getFile().indexOf(pid) == -1) { fa.setFile("C:/temp/log_BPEL_" + pid + ".log"); fa.activateOptions(); } }
logger.log(Level.INFO, message);
<extensionActivity> <bpelx:exec name="Java_Log_JUL_LOG4J" language="java"> <![CDATA[ org.packt.log.LogDynamic.log("Hello from Log4J process with id: " + getInstanceId(), ""+ getInstanceId()); ]]> </bpelx:exec> </extensionActivity>