In canonical ensemble, you have a heat reservoir ($L$) and the observed system ($l$).
The total energy is $E_{tot} = E_L +E_l$, and is a constant because the total system $(L+ l)$ is isolated.
The probability $p_l$ of finding the observed system in a microscopic state of energy $E_l$ is equal to the probability of finding the heat reservoir in a microscopic state of energy $E_L$, that is :
$$p_l = \frac{\Omega_L(E_L)}{\Omega_{TOT}}$$
where $\Omega_L(E_L)$ is the number of microscopic states for the heat reservoir, and $\Omega_{TOT}$ is the number of microscopic states for the total system $(L+ l)$.
Now, by definition the entropy $S_L(E_L) = k \ln \Omega_L(E_L)$.
Because $E_l = (E_{TOT} - E_L) << {E_{TOT}}$, we can write :
$S_L(E_L) = S_L(E_{TOT}) + (E_L - E_{TOT} ) \frac{\partial S}{\partial E}$
By definition of the temperature, we have : $\frac{\partial S}{\partial E} = \frac{1}{T}$
So : $S_L(E_L) = S_L(E_{TOT}) + (E_L - E_{TOT} ) \frac{1}{T} = S_L(E_{TOT}) - \large \frac{E_l}{T}$
So we have :
$$ln (p_l) = ln (\Omega_L(E_L)) - ln (\Omega_{TOT}) = \frac{S_L(E_L)}{k} - ln (\Omega_{TOT})$$
That is :
$$ln (p_l) = \frac{ - E_l}{k T} + \frac{S_L(E_{TOT})}{k}- ln (\Omega_{TOT})$$
The last two terms are constant, so we could write, taking the exponential :
$$p_l = A e^{\large \frac{ \large - E_l}{k T}}$$