Step 1: Check the options with the condition:
Substitute $x = 0$, $y = 1$ in option (B): $0 + 1 + 1 = 2$. True. In option (A): $0 + 1 + 1 = 2 \ne 1$. In option (C): $2 + 1 = 3 \ne 2$. In option (D): $\log2 + 1 \ne 1$.
Step 2: Verify (B) satisfies the equation:
Differentiate $\log y + y + e^x\cos^2x = 2$: $\left(\frac1y + 1\right)y' + e^x(\cos^2x - \sin2x) = 0$, which rearranges to the given equation. So (B) is correct.
Final Answer:
Option (B).
\[ \boxed{\text{(B)}} \]