MMBase tips

Logging with mm:log

tip #19 / Fri 1 Jul 2011 / André / 0 comments

The mm:log tag can print messages from your templates in the MMBase log file.

MMBase page logging is normally set to level info, the following will quite certainly print something in your log file.

<mm:log level="info">Log this to the log file</mm:log>

Result in 'INFO PAGE.LOGTAG.test.jsp log.49  - 0: Log this to the log file'. When page logging is set to 'service' you may omit the 'level' attribute.

<mm:log>This is print when page logging is set to SERVICE.</mm:log>
But I find it more convenient to use <mm:log level="info" /> when debugging and delete them when I am done. Variables are shown as follows, for example a parameter named 'param'.
<mm:import externid="param" />
<mm:log level="info">param: ${param}</mm:log>

N.B. The 'level' attribute exists since version 1.9 of MMBase. In previous versions you'll need to use the 'jspvar' attribute, for example named 'log' like in the following code snippet.

<mm:import externid="param" jspvar="param" vartype="String" />
<mm:log jspvar="log"><% log.info("param: " + param); %></mm:log>


RSS feed

Tweet this article

Most mentioned links:

MMBase documentation
MMBase Taglib reference
The reference for all tags mm