CLI:
# Print DataPower log to standard out (all available entires)
dpbuddy tail -lines "-1"
# Tail DataPower log, if domainPatterns matches multiple domains,
# tailLog will consolidate logs from these domains
dpbuddy tail -domainPatterns "dpbuddy-.*, e2e.*" -lines 100
# You can also change the log format.
# The following template will add transaction ID to the log.
# See User Guide for more details
# You can specify any logTarget configured on the device
dpbuddy tail -logTarget "default-log" -format "{1,date,yyyy-MM-dd HH:mm:ss} |{2}| {4,number,#} | {0}{3}"
# Save all log entries from the device locally
dpbuddy tail -lines "-1" -logFile "\${java.io.tmpdir}/dp.log" -appendTimestamp
# Log the message to the device's system log
dpbuddy log -level info -category all -message="Hello from DPBuddy"
# Set logging level on the device for the 'all' category
dpbuddy setLogLevel -level INFO
Ant:
<project name="dpbuddy.samples.log" basedir="." xmlns:dp="antlib:com.myarch.dpbuddy" >
<description>
Examples demonstrating DataPower log-related tasks
</description>
<!-- Print DataPower log to standard out (all available entires) -->
<target name="print.log">
<dp:tailLog lines="-1" />
</target>
<!-- Tail DataPower logs -->
<target name="tail">
<!-- If domainPatterns matches multiple domains, tailLog will consolidate logs from these domains -->
<dp:tailLog domainPatterns="dpbuddy-.*, e2e.*" lines="100" />
<!-- You can also change the log format. The following template will add transaction ID to the log. See User Guide for more details -->
<!-- You can specify any logTarget configured on the device -->
<dp:tailLog logTarget="default-log" format="{1,date,yyyy-MM-dd HH:mm:ss} |{2}| {4,number,#} | {0}{3}"/>
<!-- You can also filter out all log entries that do not match the class and object names
specified in the 'where' elements. Both class and object are regexps -->
<dp:tailLog failOnError="false" >
<where class="wsgw" object="testService.*" />
<where class="xmlfire.*" />
</dp:tailLog>
</target>
<!-- Save all log entries from the device locally -->
<target name="download.log">
<dp:tailLog lines="-1" logFile="${java.io.tmpdir}/dp.log" appendTimestamp="true" />
</target>
<target name="log.message" description="Log message to the device's system log">
<dp:log >
Hello from DPBuddy!
</dp:log>
<dp:log level="info" category="all" message="Hello again from DPBuddy"/>
</target>
<target name="set.log.level" description="Set logging level on the device for the 'all' category">
<dp:setLogLevel level="INFO" />
</target>
<!-- You can continuously tail logs using 'follow=true'.
If any of the failPatterns matches, tailLog will fail the build. -->
<target name="tail.follow" >
<!-- If follow is set to true, tailLog will be querying the device every 3 seconds
(can be changed using followInterval attribute). This is similar to tail -f Unix command -->
<dp:tailLog failPatterns="\|[E]\|" follow="true" />
</target>
<target name="log.all" depends="print.log,tail,download.log,log.message,set.log.level" />
</project>