velocityxwiki

Apache Velocity log to console for debugging


Using Apache velocity in xwiki, how do I create a console.log() like one would in JavaScript? I know the log will probably be server side. I really just want to print the values of variables as it is rendered for debugging purposes.

I should add that the page I'm trying to debug is a form .post page, thus not rendered by its self, only returns data. Thus {{velocity output="false"}} mode, so simply printing the variable is not an option.


Solution

  • Since XWiki 6.1 you can use logging script service to get a standard logger:

    $services.logging.getLogger('My script').info('Hello {}', 'world')

    See http://extensions.xwiki.org/xwiki/bin/view/Extension/Logging+Module#HGetaLoggerfromscript for more details.