Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The main hook for any use case involving this sort of thing is theĀ $custom Velocity variable that is supplied by the IdP into most of the templates at runtime. This variable simply points to any Java bean you define with the name shibboleth.CustomViewContext, which is conventionally defined in conf/global.xml so that it's visible to all the views in the system. By default there isn't such a bean, so you have to define it.

...

Code Block
languagexml
<!-- ... somewhere in global.xml... -->

<util:map id="shibboleth.CustomViewContext">
	<entry key="Logger">
		<bean class="org.slf4j.LoggerFactory" factory-method="getLogger" c:_0="com.example.loggerthing" />
	</entry>
</util:map>

To use the logger in a Velocity template:

Code Block
## somewhere in a view template...
$custom["Logger"].debug("A thing happened...")

If you adjust the "com.example.thing" level to DEBUG, the idp-process log will contain:

Code Block
12:36:55.855 - 192.168.1.1 - DEBUG[com.example.thing:-2] - A thing happened...