Exponential and Logarithmic Differentiation.

Q. If $x{e}^{xy}=y+{\mathrm{sin}}^{2}x$, then find $\frac{dy}{dx}$ at x=0.

If we differentiate the function directly as follows:

${e}^{xy}+x{e}^{xy}[y+x\frac{dy}{dx}]=\frac{dy}{dx}+\mathrm{sin}\left(2x\right)$

At x=0 We have

$1+0=\frac{dy}{dx}+0$ which gives

$\frac{dy}{dx}=1$

But if we apply logarithm and differentiate we have:

$\mathrm{log}\left(x\right)+xy=\mathrm{log}(y+{\mathrm{sin}}^{2}x)$ which when differentiated gives

$\frac{1}{x}+y+x\frac{dy}{dx}=\frac{\frac{dy}{dx}+\mathrm{sin}2x}{y+{\mathrm{sin}}^{2}x}$

If we take x=0 here, we get undefined values. And we are unable to obtain the value of dy/dx individually. Is there any mistake in the logarithmic method?