0
這可能只是我的一個愚蠢的錯誤,但我似乎無法找到它。TensorFlow日誌沒有顯示在控制檯和文件
我想在我的控制檯和日誌文件中看到來自TensorFlow的日誌,它適用於我所有的代碼,但TensorFlow部分。
我已經配置日誌是這樣的:
from logging.config import dictConfig
...
# Setup Logging
LOGGING_CONFIG = dict(
version=1,
formatters={
# For files
'detailed': {'format':
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'},
# For the console
'console': {'format':
'[%(levelname)s] %(message)s'}
},
handlers={
'console': {
'class': 'logging.StreamHandler',
'level': logging.DEBUG,
'formatter': 'console',
},
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'level': logging.DEBUG,
'formatter': 'detailed',
'filename': LOG_FILE,
'mode': 'a',
'maxBytes': 10485760, # 10 MB
'backupCount': 5
}
},
root={
'handlers': ['console', 'file'],
'level': logging.DEBUG,
},
)
dictConfig(LOGGING_CONFIG)
我研究這個問題,並得知我不得不啓用日誌記錄在TensorFlow像這樣的東西:
import tensorflow as tf
...
tf.logging.set_verbosity(tf.logging.INFO)
不幸的是這似乎並不工作 - 日誌不顯示。如果我使用logging.basicConfig()
而不是我自己的配置,則會按預期顯示日誌。在這種情況下,日誌將打印到我的終端。
我的結論是,我的日誌配置有點錯誤 - 請幫助我。