This snippet doesn’t print anything:
import logging
import numpy as np
logging.info(np.eye(4))
# this doesn't work either
logging.info('matrix', np.eye(4))
But it works fine with native print:
import logging
print(np.eye(4))
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
>Solution :
I think the issue is with your logging level.
If I try logging.warning(np.eye(4)), I get an output in my console.
Try the following code:
import logging
import numpy as np
# Fix logging level issue
logging.getLogger().setLevel(logging.INFO)
logging.info(np.eye(4))
Output:
INFO:root:[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]