But is it really true that $\log(xy) = \log(x)+\log(y)$ 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?
 A: 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

For every positive real numbers $x$ and $y$, $\log(x)+\log(y)=\log(xy)$

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).
A: If we work with real valued logarithm and if we only have the constraint $xy>0$, you can derive the similar logarithm rule:
$$
\begin{align}\log(xy)&=\log \left(|xy|\right)\\
&=\log \left(|x|×|y|\right)\\
&=\log |x|+\log |y|.\end{align}
$$
In general, note that
$$\log (xy)=\log x+\log y$$
holds, iff $x>0\wedge y>0$.
A: If you define it via integral formula i.e. $\displaystyle \ln(x)=\int_1^x \dfrac{dt}t$
You can see that you need the interval $[1,x]$ (or $[x,1]$ if $x<1$) to not cross $0$ else the integral would be divergent, which consequently means that $x$ must be strictly positive.
The multiplication to addition formula can be proven this way ($a,b>0$):
First by substituting $u=\frac 1t$ then $$\ln(\tfrac 1x)=\int_1^{\frac 1x}\dfrac{dt}{t}=\int_1^x \dfrac{-u\mathop{du}}{u^2}=-\int_1^x du=-\ln(x)$$
Then by substituting $t=bu$ then
$$\ln(ab)=\int_1^{ab}\dfrac{dt}{t}=\int_{\frac 1b}^a \dfrac{b\mathop{du}}{bu}=\int_{\frac 1b}^a \dfrac{du}{u}\ \overset{(*)}{=}\ \ln(a)-\ln(\tfrac 1b)=\ln(a)+\ln(b)$$
Justification of (*):

*

*It is straightforward when $a,b>0$ since we can rewrite $\displaystyle\int_{\frac 1b}^1 \frac{du}{u}+\int_1^a \frac{du}{u}\ $ and then use the definition.


*On the contrary when $a,b<0$ this split is not possible since each individual integral is divergent. But we can substitute $v=-u$ and get
$$\int_{\frac 1b}^a \dfrac{du}{u}=\int_{-\frac 1b}^{-a} \dfrac{-dv}{-v}=\int_{\frac 1{|b|}}^{|a|} \dfrac{dv}{v}=\ln(|a|)+\ln(|b|)$$
Now with $|a|,|b|>0$ the split is possible.
In the end the "true" formula is rather:

*

*if $\ln(a),\ln(b)$ are defined (i.e. then $a,b>0$) then their sum is equal to $\ln(ab)$

*if $\ln(ab)$ is defined (i.e. $ab>0\iff\{a,b>0\}\lor\{a,b<0\}$) then it is equal to $\ln(|a|)+\ln(|b|)$
Yet commonly the case where $a,b$ are both negative is not very frequent, and the usage settled for the omission of the absolute values.
