Add a logging hook.