Tuesday, 15 August 2017

Adding New Logger for OIM Custom Code

When we write any custom code for scheduler, event handler or for adapter in OIM, if we use System.out.println, all the statements will be printed to the common server log.

Common server log contains all the OIM's operations logs, and if our custom code logs are also merged with this, then it will be very difficult for debug.

The best practice is to create a custom logger for our custom code. It is also applicable for any WebLogic based application.


Steps to Create Custom Logger

1. Go to the [DOMAIN_HOME]/config/fmwconfig/servers/[SERVER_NAME]. In this case the   SERVER_NAME is the oim server name.
2. Open the logging.xml in editor mode.
3. Add the Log Handler and Logger as below



Log Handler

<log_handler name='oim-custom' class='oracle.core.ojdl.logging.ODLHandlerFactory' level='FINEST'>
   <property name='useDefaultAttributes' value='false'/>
   <property name='format' value='ODL-Text'/>
   <property name='path' value='/u01/oracle/log/oim-custom.log'/>
   <property name='maxFileSize' value='10485760'/>
   <property name='maxLogSize' value='52428800'/>
   <property name='useSourceClassAndMethod' value='TRACE:1'/>
  </log_handler>


Logger

<logger name='OIM-CUSTOM' level='FINEST'>
   <handler name='oim-custom'/>
</logger>


4. After edit close the file and restart the OIM managed server.
5. If you have more than 1 OIM servers in a cluster then, perform the same operation for all the servers. Change the [SERVER_NAME].

6. Now you can use the new logger in your java code like below

final Logger logger = Logger.getLogger("OIM-CUSTOM");
logger.info("YOUR LOG MESSAGE");


Note: "OIM-CUSTOM" is your logger name.

No comments:

Post a Comment

Followers

OIM API for adding process task and retry failed task

 In this blog you can find how to add new process task and retry any failed/rejected tasks using API. Adding new process task: /************...