Generalized Krein formula, determinants, and Selberg zeta function in even dimension