我想決議java日志。我只需要使用跟蹤器獲取錯誤日志。
例如:
2022-06-21 19:19:56,665 ERROR [scheduler-3] o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task
java.lang.NullPointerException: null
at ...
at ...
...
2022-06-21 19:19:56,666 DEBUG
我需要全部使用,直到有資料的新日志行。這是:
2022-06-21 19:19:56,665 ERROR [scheduler-3] o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task
java.lang.NullPointerException: null
at ...
at ...
...
使用重復符號為該任務制作正則運算式的最佳方法是什么?以我的方式有類似的東西. \n\t
如果我不使用重復它看起來很丑,REG_EXP_2 = r'\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\sERROR. \n. \n\t. \n\t. '
所以我需要找到所有帶有模型的日志字串,. \n\t直到我找到新的資料行。
我嘗試使用帶有重復符號的模型,但它只決議最后一個查找字串。
謝謝你。
uj5u.com熱心網友回復:
要匹配 ERROR 和以下所有不以日期開頭的行:
^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\sERROR\b.*(?:\n(?!\d{4}-\d{2}-\d{2}\s).*)*
正則運算式演示
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/495203.html
上一篇:CSV的列串列結構
