4 votes

XSLT LogHelper


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"/>
<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>



Archived files


Source code

Package owner

Jonas Eriksson

Jonas Eriksson

Jonas has 1825 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions:

Package Information

  • Package owner: Jonas Eriksson
  • Created: 19/03/2010
  • Current version 0.9
  • License MIT
  • Downloads on Our: 921

External resources