Fix recursion issue with logging handler