Add environment and fix logging