  We find a connection between logarithmic formation probabilities of two
disjoint intervals of quantum critical spin chains and the Casimir energy of
two aligned needles in two dimensional classical critical systems. Using this
connection we provide a formula for the logarithmic formation probability of
two disjoint intervals in generic $1+1$ dimensional critical systems. The
quantity is depenedent on the full structure of the underlying conformal field
theory and so useful to find the universality class of the critical system. The
connection that we find also provides a very efficient numerical method to
calculate the Casimir energy between needles using quantum critical chains. The
agreement between numerical results performed on critical transverse field
Ising model and XX chain with our exact results is very good. We also comment
on the mutual R\'enyi information of two disjoint intervals.
