We will talk about a formula computing the first Chern class of a line bundle in terms of residues of a given connection. This localization formula unifies two results on stable sets of holomorphic foliations of codimension 1. The first result is a positive answer to Brunella's conjecture, stating that every leaf of such a foliation with ample normal bundle in compact complex manifolds of dimension ≥ 3, accumulates on singularities of the foliation. The second result states the non-existence of real analytic Levi-flat hypersurface whose Levi foliation is transversally affine and of 1-convex complement in compact Kähler surfaces. This is a joint work with Masanori Adachi et Judith Brinkschulte.