one doubt that I have is why do we use
-log

from what I understand is that, it has to do with number of bits that would be required to represent that probability
for example, if our model predicted a probability of 1 for the correct class, then
-log(1)

would be zero, so we do not need any bits, the model’s prediction is correct for what class our input belongs to
if our model gives a probability of 0.5 for the correct class, then
-log(0.5)

would be 1 [assume we take log base 2, as (log of input base e) is ((log of input base 2)/(log of e base 2)), so maybe it does not make a difference]
so it is interpreted as our model needs 1 bit to represent this probability, that is something like,
0
1

if prob was 0.25, then 2 bits, something like,
00
01
10
11

so we want to reduce this number of bits required to represent our prediction, but I am not sure about this, I think there is something more behind use of -log