Changing the denominator to $x^2$ is a multi-step process which need not be shown in detail in an exam, but for a student it is absolutely necessary to know all the steps involved.
Thus one write $x\sin x$ as $x^2\cdot\dfrac{\sin x} {x} $ and notice that the fraction $\dfrac{\sin x}{x} $ occurs in the overall expression under limit in a multiplicative manner and has a non zero limit. Thus as explained in this answer the fraction can be replaced by its limit $1$ and the denominator changes to $x^2$.
For the numerator you are trying to use the limit $$\lim_{x\to 0} \frac{\log(1+\tan x)} {\tan x} =1$$ But this can work only if the ratio $$\dfrac{\log(1+\tan x)} {\tan x}$$ is available as a factor (occurs in a multiplicative manner) or as a term (occurs in an additive manner) in the overall expression.
Also note that changing the denominator to $x^2$ is a valid step (as shown above) and this step looks the same as replacing $\sin x $ by $x$ (in reality it is replacing $\lim_{x\to 0}\dfrac{\sin x} {x} $ by $1$) the same can't be done with the $\sin x $ occurring in numerator. The fact that the ratio $$\frac{\log(1+\tan x) - x} {x^2}$$ has the same limit as that of the original expression is just a coincidence and it does not validate the replacement of $\sin x$ by $x$ in numerator.
In spite of the simplicity of limit laws it is a great irony that most beginners simply don't understand them and their correct usage. In fact many are not even aware that limits are evaluated by the use of limit laws.
A simple solution based on limit laws and standard limits is presented below. First we can change the denominator to $x^2$ and split numerator by adding subtracting $\tan x$ to get the expression under limit as $$\frac{\log(1+\tan x) - \tan x} {x^2}+\frac{\tan x - \sin x}{x^2} $$ At this stage we don't know if both the fractions above have well defined limits or not. But we can try to see if they have limits. As before the denominator of first fraction can be replaced with $\tan^2x$ and substitution $t=\tan x$ gives us the ratio $$\frac{\log(1+t)-t}{t^2}$$ And this should look familiar to anyone who has evaluated a lot of limits. You can use either L'Hospital's Rule or Taylor series to show that the ratio above tends to $-1/2$.
The second fraction $\dfrac{\tan x - \sin x} {x^2}$ can be rewritten as $$\frac{\sin x} {x} \cdot\frac{1-\cos x} {x^2}\cdot \frac{x} {\cos x} $$ and thus tends to $1\cdot\dfrac{1}{2}\cdot\dfrac{0}{1}=0$. It is now clear that the desired limit is $-1/2$.