We probably all know that
$$\log (x y)=\log x + \log y$$
However the expression on the left needs only $x y >0$ to be defined, whereas the expression on the right requires $x>0$ and $y>0$.
For example suppose you were maximizing $$\max \log(x)+\log(y), s.t. constraints$$
vs
$$\max \log(xy) s.t. constraints$$
The two problems seem to be entirely different, although a naive substitution would imply that the two are identical.
My question is: Is this point discussed anywhere? I haven't come across a discussion of this. Are there any references to find more on that?
You are right: Formulas and theorems come with conditions on the variables they are about. $\log(x)+\log(y)=\log(xy)$ is false. What is true is
I guess that some people would consider that, when writing $\log(x)+\log(y)=\log(xy)$, it is implicitly assumed that each number exists (here, $x$ and $y$ are positive), but I think it is a bad habit, especially for students.
This has practical implications. As an example, the equation $2\log(x+1)-\log(x+3)=0$ is NOT equivalent to $\log\left( \frac{(x+1)^2}{x+3} \right)=0$ since $-2$ is a solution of the latter but not of the former ($\log(-1)$ is not defined).
Your optimization problem is another example. In maximizing $\log(xy)$, you have the constraint that the product $xy$ should be positive (so $x$ and $y$ are nonzero and have the same sign), while in maximizing $\log(x)+\log(y)$, the constraints are stronger ($x$ and $y$ should be positive).