Formula for group commutator in terms of Lie bracket

Statement
This is a formula that tries to express:

$$\log([\exp(X),\exp(Y)])$$

in terms of $$X$$ and $$Y$$. Here $$X$$ and $$Y$$ are elements of a Lie algebra or Lie ring, $$\exp$$ is the exponential map from the Lie algebra to its Lie group, the expression $$[\exp(X),\exp(Y)]$$ denotes the group commutator of $$\exp(X)$$ and $$\exp(Y)$$, and $$\log$$ is the inverse of the exponential map.

The expression is as a $$\mathbb{Q}$$-linear combination of $$[X,Y]$$ and higher order brackets involving $$X$$ and $$Y$$.

The formula can be deduced from the Baker-Campbell-Hausdorff formula.

Note that the precise formula depends on the choice of convention we choose for commutator, i.e., whether we define $$[g,h]$$ as $$ghg^{-1}h^{-1}$$ or as $$g^{-1}h^{-1}gh$$.

Particular cases
In the case that we have a nilpotent group or equivalently a nilpotent Lie ring, the Baker-Campbell-Hausdorff formula terminates in finitely many steps, because all terms that involve more than a given number of Lie bracket iterations vanish. Below are the formulas for small values of nilpotency class.

For class $$c$$, the formula makes sense over any field or ring where all the primes less than or equal to $$c$$ are invertible.

Note that in the abelian case, the exponential map is a homomorphism, and hence the Baker-Campbell-Hausdorff formula just gives $$X + Y$$.