We often may want to use our own loggers in our codes, for the sheer benefit of ease of troubleshooting, instead of the normal OUT or diagnostic logs.
Oracle Diagnostic Logging (ODL) is the principal logging service used by Oracle Identity Manager. For ODL logging to work, both loggers and log handlers need to be configured. Loggers send messages to handlers, and handlers accept messages and output them to log files.
ODL recognizes five message types: INCIDENT_ERROR, ERROR, WARNING, NOTIFICATION, and TRACE. Each message type can also take a numeric value between 1 (highest severity) and 32 (lowest severity) that we can use to further restrict message output.
The configurations are stored in the logging.xml file, which we can find in the location : DOMAIN_NAME/config/fmwconfig/servers/SERVER_NAME/
The logging.xml file has a <log_handlers> configuration section, followed by a <loggers> configuration section. Each log handler is defined within the <log_handlers> section, and each logger is defined within the <loggers> section.
When configuring a logger to write messages to either the console or a file, make configuration changes to both the logger and the handler. Setting the level attribute for the logger configures the amount of detail (and therefore, the volume of messages) that the logger sends to the handler.
Similarly, setting the level attribute for the handler configures the amount of detail that the handler accepts from the logger.
An example of a log_handler will be :
This will define the path and file where the logs will be printed in, also, the encoding as well as the size, format etc.
<log_handler name='EXAMPLE-HANDLER-ONE' class='oracle.core.ojdl.logging.ODLHandlerFactory' level='FINEST'>
<property name='logreader:' value='off'/>
<property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/EXAMPLE-HANDLER-ONE.log'/>
<property name='format' value='ODL-Text'/>
<property name='useThreadName' value='true'/>
<property name='locale' value='en'/>
<property name='maxFileSize' value='104857600'/>
<property name='maxLogSize' value='1048576000'/>
<property name='encoding' value='UTF-8'/>
</log_handler>
An example of a logger will be :
<logging_configuration>
<loggers>
<logger name='example.logger.one' level='FINEST' useParentHandlers='false'>
<handler name='EXAMPLE-HANDLER-ONE'/>
<handler name='EXAMPLE-HANDLER-TWO'/>
<handler name="console-handler"/>
<!--Additional logger elements defined here....-->
</logger>
</loggers>
</logging_configuration>
NOTE :
Now, we're free to use the error messages in our code in the below mentioned way -
private static final Logger LOGGER = Logger.getLogger("example.logger.one");
LOGGER.debug("WRITE_YOUR_OWN_MESSAGE");
LOGGER.info("WRITE_YOUR_OWN_MESSAGE");
We can also change the level of an existing logger from the EM console -
1. Log-into EM console
2. Navigate to “Identity and Access” -> OIM -> oim(11.1.2.0)
3. Right-click and navigate to Logs -> Log configuration.
Change the level of the specific logger from drop down -
Thanks for reading !
Oracle Diagnostic Logging (ODL) is the principal logging service used by Oracle Identity Manager. For ODL logging to work, both loggers and log handlers need to be configured. Loggers send messages to handlers, and handlers accept messages and output them to log files.
The configurations are stored in the logging.xml file, which we can find in the location : DOMAIN_NAME/config/fmwconfig/servers/SERVER_NAME/
The logging.xml file has a <log_handlers> configuration section, followed by a <loggers> configuration section. Each log handler is defined within the <log_handlers> section, and each logger is defined within the <loggers> section.
When configuring a logger to write messages to either the console or a file, make configuration changes to both the logger and the handler. Setting the level attribute for the logger configures the amount of detail (and therefore, the volume of messages) that the logger sends to the handler.
Similarly, setting the level attribute for the handler configures the amount of detail that the handler accepts from the logger.
An example of a log_handler will be :
This will define the path and file where the logs will be printed in, also, the encoding as well as the size, format etc.
<log_handler name='EXAMPLE-HANDLER-ONE' class='oracle.core.ojdl.logging.ODLHandlerFactory' level='FINEST'>
<property name='logreader:' value='off'/>
<property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/EXAMPLE-HANDLER-ONE.log'/>
<property name='format' value='ODL-Text'/>
<property name='useThreadName' value='true'/>
<property name='locale' value='en'/>
<property name='maxFileSize' value='104857600'/>
<property name='maxLogSize' value='1048576000'/>
<property name='encoding' value='UTF-8'/>
</log_handler>
An example of a logger will be :
<logging_configuration>
<loggers>
<logger name='example.logger.one' level='FINEST' useParentHandlers='false'>
<handler name='EXAMPLE-HANDLER-ONE'/>
<handler name='EXAMPLE-HANDLER-TWO'/>
<handler name="console-handler"/>
<!--Additional logger elements defined here....-->
</logger>
</loggers>
</logging_configuration>
NOTE :
- A logger can inherit a parent logger's settings, including the parent's level setting and other attributes, as well as the parent logger's handlers.
- At the top of the logger inheritance tree is the root logger. The root logger is the logger with an empty name attribute.
Now, we're free to use the error messages in our code in the below mentioned way -
private static final Logger LOGGER = Logger.getLogger("example.logger.one");
LOGGER.debug("WRITE_YOUR_OWN_MESSAGE");
LOGGER.info("WRITE_YOUR_OWN_MESSAGE");
We can also change the level of an existing logger from the EM console -
1. Log-into EM console
2. Navigate to “Identity and Access” -> OIM -> oim(11.1.2.0)
3. Right-click and navigate to Logs -> Log configuration.
Change the level of the specific logger from drop down -
Thanks for reading !
No comments:
Post a Comment