Zeta function regularization is one of the established tools in mathematics and physics for summing certain asymptotic series. In cases where the regularized series still diverges (such as for the harmonic series), a single series has no result but linear combination of several regularized series in which the leading divergent terms cancel make sense. It is only the latter that have a physical meaning. Thus in applications to singular interactions in quantum mechanics or quantum field theory one first must sum all relevant contributions before taking the limit where the argument attains its physical value.

In your explicit example, the first formula is valid and diverges; the second formula can be used only in combination with another, similar sum where the logarithm appears with the opposite sign, so that the divergent part cancels.

For the use of zeta function regularization in quantum field theory see, e.g., the book Analytic Aspects of Quantum Field by Bytsenko et al. (2003).

For an application in infinite-dimensional geometry see, e.g., here.