Logging to a custom file

Occasionally, you may want to separate a part of logging to a separate logging file. That way, you can instantly separate the desired logging from the main logging flow, leaving the original logging configuration untouched. In this recipe, we will define a custom logfile so that only the information we want to gather will be collected. The rest of the configuration will remain intact.

Getting ready…

For completing this recipe, you'll need a BPEL process. Any BPEL process is suitable, and of course, we need a running Oracle SOA Suite server.

How to do it…

The following steps will describe how to configure the custom logfile through the Oracle SOA Enterprise Manager Console:

  1. Start by logging in to the Oracle Enterprise Manager Console. On the soa-infra node, right-click and select Logs | Log Configuration as shown in the following screenshot:
    How to do it…
  2. Choose the Log Files tab and click on the Create… button. A pop-up window appears where you configure the custom logging file. You have to supplement the mandatory fields and choose loggers in the Loggers To Associate drop-down list as shown in the following screenshot:
    How to do it…
  3. After the successful completion of the configuration, you'll receive a confirmation message as shown in the following screenshot:
    How to do it…
  4. custom-handler is now listed in the table of logfiles. There is no need to restart the server.

How it works…

The location of the logging configuration for the Oracle SOA Suite is held in the ${domain.home}configfmwconfigserversAdminServer directory. More precisely, the file containing the logging information is named logging.xml. Let's check the configuration file. The changes we made through the Oracle Enterprise Manager Console appeared in the following files:

  • The following are the changes in the configuration of log file:
    <log_handler name='custom-handler' class='oracle.core.ojdl.logging.ODLHandlerFactory' level='NOTIFICATION:32'>
      <property name='useDefaultAttributes' value='false'/>
      <property name='format' value='ODL-Text'/>
      <property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/customLogFile.log'/>
      <property name='useSourceClassAndMethod' value='TRACE:1'/>
    </log_handler>

In the preceding code, with the name attribute of the <log_handler> element, we define the name of the log handler. With the format property, we define the format of the logging data to be used. We can choose either text or XML format. With the path property, we define the location of the logfile. With the useSourceClassAndMethod property, we define the logging level to be used for logging information.

  • The following are the changes in the configuration of loggers reporting to the newly created logfile:
    <logger name='oracle.soa.bpel.engine.xml'>
      <handler name='custom-handler'/>
    </logger>

Logging in the Oracle SOA Suite is based on Java Logging functionality. Although the configuration itself is separated, there is nothing stopping you from using Java Logging elements.

Now that we have logging configured, it is time to start an instance of the BPEL process to check what gets logged. We have set the logging level to TRACE, so we should get quite a verbose output in the custom logfile. You can run the BPEL process from Assigning date or time to the variables recipe defined in Chapter 7, Accessing and Updating the Variables. By examining the logfiles, you will see the following lines of code (the beginning of the lines are truncated for better readability):

[SRC_METHOD: evaluate] XPathQuery[xp20:current-time()], XPath Result is: 13:05:32.429+02:00
[SRC_METHOD: evaluate] XPathQuery[xp20:format-dateTime(bpws:getVariableData('FormatDate'), '[D01]/[M01]/[Y0001]')], XPath Result is: 01/05/2013
[SRC_METHOD: evalQuery] evaluate PathQuery[/client:proces sResponse/client:result] on oracle.xml.parser.v2.XMLElement@64feb8

With this output, we are able to identify what evaluations are performed in the BPEL process due to the XML operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset