The given equation is:
\[
\ln\left(\frac{x + y}{2}\right) = \frac{1}{2}\left[\ln(x) + \ln(y)\right].
\]
Step 1: Simplify using logarithmic properties.
Using the property of logarithms, \( \ln(ab) = \ln(a) + \ln(b) \), the right-hand side can be rewritten as:
\[
\frac{1}{2}\left[\ln(x) + \ln(y)\right] = \ln\left(\sqrt{xy}\right).
\]
Equating both sides, we get:
\[
\ln\left(\frac{x + y}{2}\right) = \ln\left(\sqrt{xy}\right).
\]
Step 2: Exponentiate both sides.
By removing the logarithm, we have:
\[
\frac{x + y}{2} = \sqrt{xy}.
\]
Step 3: Solve for \( \frac{x}{y} + \frac{y}{x} \).
Square both sides:
\[
\left(\frac{x + y}{2}\right)^2 = xy \implies \frac{(x + y)^2}{4} = xy \implies x^2 + y^2 + 2xy = 4xy.
\]
Simplify to find \( x^2 + y^2 \):
\[
x^2 + y^2 = 2xy.
\]
Thus:
\[
\frac{x}{y} + \frac{y}{x} = \frac{x^2 + y^2}{xy} = \frac{2xy}{xy} = 2.
\]
Final Answer:
\[
\boxed{2}
\]