If I define a function, I get to tell you what its domain is. There's a function ##\log : (0,\infty)\to \mathbb{R}## that some people defined. By fiat, its domain is ##(0,\infty)##, and so it doesn't make any sense to ask what ##\log(x)## is for ##x\notin(0,\infty)##.

Now, the question to ask would be why some people defined ##\log## as a function with domain ##(0,\infty)##. To know for sure, we would have to be able to read minds.

One guess is that it's nice for the equation ##\log(x) = \int_1^x \frac1t \text{ d}t## (where the right-hand side is a Riemann integral) to hold for every ##x## in the domain. This would force us to avoid ##x<0##, lest the integral not be well-defined. It would also force us to avoid ##x=0## if we want the function to be real-valued (and in particular not take on the value ##-\infty##).

Of course, you could always define an alternative function with a bigger domain, say ##\mathbb R## or ##[0,\infty)## or ##[-12.3, \infty)##, which agrees with ##\log## on ##(0,\infty)## and takes some values you specify for other inputs. But then you would be defining a new function.

Another way of looking at it (though, frankly, I prefer the approach economicsnerd is taking) is that ln(x) can be defined as the inverse function to [tex]y= e^x[/tex]. Since that is a positive number to the x power, while x can be any number, y must be positive (less than 1 of x< 0, greater than 1 if x> 0). Reversing, x= log(y), so that, while the value of the function can be any number, the "domain" is all positive numbers.

mather, consider changing the base of the logarithm. Can you have a negative base? Does this logarithm have a solution?$$\log_{-2}{4}$$How about this one?$$\log_{-2}(-8)$$
To answer these you must consider the definition of the logarithm to be $$\log_{b}{c}=a \iff b^a=c$$You can see that we are given ##b## and ##c## and we need to find ##a##. If you take ##b## and ##c## and plug them into the equation ##b^a=c##, you can sometimes recognize the value of ##a##.

Now consider ##b=e=2.718## and ##c=..## say.. ##-2##. Evaluate ##\log_{e}(-2)=\ln(-2)##. In other words, find the value of ##a## so that ##e^a=-2##. In other words, plot the function ##y=e^x## and find where ##y=-2##. What x value does this occur at? Are there any better negative values to try besides -2? What about 0?

This is why for some bases (positive bases in particular) you can't take the logarithm of a negative number or zero. In fact, you can take these types of logarithms if you know how logarithms behave in the complex numbers. But before you can understand that, you need to understand what it means when you have an imaginary number in an exponent. Say.. ##e^{i\theta}## where ##\theta## is a constant.

But there is no natural and unambiguous definition of, say, negative number in the power ½.

That’s why logarithms of negative numbers are so messy. What can we hope to achieve? If we chose a negative base, such as −2, then we have logarithms of its powers, such as 4, −8, 16, −32… half of those are negative. But for a negative base we fail with all other numbers, that are not integer powers of the base. This is a valid topic for number theory, but useless in calculus.

Another possibility is to find a complex power of a positive base, that results in given negative number. That’s how logarithm is understood in complex analysis and calculus in general, but it is a multivalued function.

In neither case you can obtain log 0. Any power of a non-zero number is not zero, whereas log0 is ill-defined.