This is similar to asking why `sqrt(-1)` is not defined. It is not defined if we're thinking in terms of real numbers, but if we expand our definition of "number" to include complex numbers, then it is defined, and it's `i.`
Similarly, we can define logarithms for all nonzero complex numbers (which include negative numbers). We have to make a choice which logarithm to take, since there will in general be more than one. This choice is called the principal logarithm of the number. The principal logarithm of `-1` is `pi i`, for example. The details are a little sophisticated and they're in the link below.
So, logarithms can be defined for negative numbers, but we have to use complex numbers to do it. If we insist on sticking with real numbers, then justaguide explained well why we won't be able to define logarithms for negative numbers.
If three numbers X, a and b are related by `X = a^b` , the following logarithmic form applies: `log_a X = b`
The logarithm of a negative number is not defined as a negative number is equal to the odd power of a negative number. For X to be negative in the earlier relation, a has to be a negative number and b has to be odd. If a were negative, for most values of X, there wouldn't be a corresponding value for b.
To ensure that the logarithm of a number is unique and defined it is essential to restrict the set of numbers for which a logarithm exists to the set of positive real numbers.
If m is even integer then for `+-a` ,b is unique.
If m is odd integer then for `+-a ,` b is also `+-b` . This is one restricted definition. If m is real number then there may be problem. For example `(-1)^(1/2)` ,(-1) is real number , (1/2) is rational number but `(-1)^(1/2)` is not real number. So we wish to avoid this situation and restrict our self for a>0 only.But then
`a^m=b>0 AAm` , and m ,b are real number. Since there does not any real number m for which `a^m=0` .Therefore b can not be zero.
Now let define a new relation as
Since b >0 ( from above restriction) . Therefore log function defined only for positive real numbers.