Friday 29 April 2016

DataPower Logging

DataPower has provided easy way to allow developers to create log entries or capture information related to a transaction. If you are familiar with Java, it's more like log4j where you have appenders and log levels. Before I dive into implementation details, let me start with few important words and their definitions

1. Log Category - DataPower comes with few default log category and also allows to create new ones. Think log category as tags. Say if you want to generate some logs, you can tag each log entry. The purpose is to differentiate logs by applying tags. Say from your XSL you want to generate 5 different kind of logs, then you can just have 5 different tags. Each log entry will be fired with the specified log category.

2. Event priority - is like log levels. DataPower doesn't provide any option to create new priorities. Few examples that comes with DataPower emergency, error, debug, information etc. 

3. Log Target -  Log target capture logs fired by services or object. Log targets are like appenders. You can have as many targets as you want. Targets allow logs to captured in DataPower files system or send to a remote server using protocol HTTP, Syslog, SMTP or NFS. Each log targets subscribes to combination of log category and event priority. 

Note: DataPower comes up with a default LogTarget that capture all log categories including customs if created on debug level and mgmt on notice level.












To create a new Log Category, search Log Category from search text box from left menu bar.
Create a new one and apply. In this case, I have create "ProjectLog01".












Now you can create a new LogTarget say "ProjectTarget01". In this log target, I've subscribed new log category with event priority "debug" which means debug or all other log entries above debug will be captured.















For example below xsl:message statement will generate a log for default log category "xsltmsg"

<xsl:message dp:priority="debug">This is a log message that will be generated for default category 'xsltmsg'</xsl:message>
view rawxsltmsg hosted with ❤ by GitHub

And this one will generate a log for "ProjectLog01" category. LogTarget "ProjectTarget01" created above will capture this entry. 


<xsl:message dp:priority="debug" dp:type="ProjectLog01">This is a log message that will be generated for category 'ProjectLog01'</xsl:message>
view rawxsltmsg hosted with ❤ by GitHub

Please put your comments if you have any specific question about DataPower logging. I will cover Probe and some other feature of DataPower in next few postings.

No comments:

Post a Comment