Why Keras Callbacks all use print but sometimes send warning or error using logging?

In most callbacks, when logging information, print is used. But the standard logging library is also used for warning or error. Why logging.info is not used instead of print ?

For example, in the ReduceLROnPlateau callback, on_epoch_end, it is the following :

print('\nEpoch %05d: ReduceLROnPlateau reducing learning rate to %s.' % (epoch + 1, new_lr))

But for the warning, the standard logging library is used :

logging.warning('Learning rate reduction mode %s is unknown, fallback to auto mode.', self.mode)

I’m currently trying to redirected the print to a logger and it would have been much simpler if logging.info was used. Any ideas on why this is done like this and if I should bother to make a PR to change that ?

Hi @VictorGalisson, In Python both print and logging are used for displaying information, but they both serve for different purposes.

logging provides different log levels such as Debug, Info, Error, Warning, and Critical. print does not have any levels, it simply prints whatever is passed to it.

For example,

logging.warning("This is logging")
#out: WARNING:root:This is logging

print("This is print")
#out: This is print

Thank You.