  In this paper we define B-Fredholm elements in a Banach algebra $A$ modulo an
ideal $J$ of $A.$ When a trace function is given on the ideal $J,$ it generate
an index for B-Fredholm elements. In the case of a B-Fredholm operator $T$
acting on a Banach space, we prove that its usual index $ind(T)$ is equal to
the trace of the commutator $ [T, T_0],$ where $T_0$ is a Drazin inverse of $T$
modulo the ideal of finite rank operators, extending a Fedosov's trace formula
for Fredholm operators. In the case of a semi-simple Banach algebra, we prove a
punctured neighborhood theorem for the index.
