# -*- coding: utf-8 -*- """票 04:从 logback 的 crm-app.log 提取最近的 ERROR 堆栈。""" import io, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') txt = open(r'e:\code\crm-backend-matt\logs\crm-app.log', encoding='utf-8', errors='replace').read() idx = txt.rfind('ERROR') print('size', len(txt)) if idx >= 0: print(txt[max(0, idx - 300):idx + 3000]) else: print(txt[-1500:])