我正在运行以下代码:# create logger logger = logging.getLogger("myApp") logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# add ch to logger
logger.addHandler(ch)
logger.debug('debug sample message')现在,在不同的python脚本上,我想读取这些消息(属于syslog中的"myApp“)--我该怎么做?
非常感谢,埃夫拉特
发布于 2016-08-21 17:01:58
您可以以文件形式读取:
important = []
keep_phrases = ["test",
"important",
"warning"]
with open("log.log" 'r') as f:
for line in f:
for phrase in keep_phrases:
if phrase in line:
important.append(line)
print line
break
print(important)https://stackoverflow.com/questions/39062464
复制相似问题