I needed a way to easily add log rows from my xslt macros, and added a single-line-extension for that reason. And for it to be a little more complete I also added a getlog-function.
For the most complete way to watch and handle log rows, I would recommend using the other logging packages, but if you for some reason need it inside your Xslt, you can use this.
Add a log row :
xsl:value-of select="LogHelper:LogAdd(-1, 'heres a comment for the log')"
Iterate the log rows from last 2 days:
xsl:for-each select="LogHelper:GetLog(2)/Log/Logrows [logHeader='Custom']
The LogAdd-function adds a row with "Custom" header.
Have fun!
I have used ideas from Niels Hartvig (HelloWorldExt) and Immo Wache (Log4Umbraco).
The whole thing is 40 or so lines of code, and you find the source at the codeplex site.
Here's a sample XSLT that adds a log row, and displays a html-table with all log rows with header "Custom" from last 1 day:
<!-- add log row -->
<xsl:value-of select="LogHelper:LogAdd(-1, 'heres a comment for the log')"/>
<!-- get log rows for 1 day and display it in a table, newest at the top-->
<xsl:variable name="getDays" select="1"/>
<table>
<tr><th>logHeader</th><th>DateStamp</th><th>userId</th><th>nodeId</th><th>logComment</th></tr>
<xsl:for-each select="LogHelper:GetLog($getDays)/Log/Logrows [logHeader='Custom']">
<xsl:sort select="./DateStamp" order="descending"/>
<tr><td><xsl:value-of select="./logHeader"/></td><td><xsl:value-of select="./DateStamp"/></td><td><xsl:value-of select="./userId"/></td><td><xsl:value-of select="./nodeId"/></td><td><xsl:value-of select="./logComment"/></td></tr>
</xsl:for-each>
</table>