In developerWorks DataPower Forum thread "Reading log files in datapower"
the question was raised how to read log files in XSLT.
A colleague responded with a first hurdle:
While each log entry in file "logtemp:///default-log-xml" is XML, the whole file is Non-XML because an enclosing document element is missing.
While each log entry in file "logtemp:///default-log-xml" is XML, the whole file is Non-XML because an enclosing document element is missing.
Reason for this is that new log messages can just be appended this way, and even rolling the log does not hurt.
A second hurdle is this logged error when trying to open the log:
"Unsupported URL 'logtemp:///default-log-xml'"
A second hurdle is this logged error when trying to open the log:
"Unsupported URL 'logtemp:///default-log-xml'"
OK -- this is a solution to read default-log-xml anyway:
- define a local HTTP service listening on 127.0.0.1:8888 with base directory "logtemp:///"
- read default-log-xml via that HTTP service with <dp:url-open ... response="binaryNode"/>
- extract the Non-XML log "text" from the response and wrap it by "<wrap>...</wrap>"
- store the log messages in a nodeset by "dp:parse(...)/*"
That's all, see the stylesheet in action here:
|
<EDIT>
In the developerWorks posting it was asked how to read arbitrary log files, just add this here for completeness.
(here are both stylesheets: log.zip)
In the developerWorks posting it was asked how to read arbitrary log files, just add this here for completeness.
(here are both stylesheets: log.zip)
The new stylesheet in action below -- reading the text log file requires parsing the lines, reading the XML log is preferable::
|
</EDIT>
Hermann < myXsltBlog/> < myXsltTweets/>