0
字符串匹配的一部分,我有兩個文件,一個是「error_dict」文件,另一種是「jbosslogfile」錯誤字典文件包含像 error_dict中的每一行知錯誤消息搜索在python
"0500 ERROR [org.picketlink.identity.federation]"
"-0500 ERROR [com.gravitant.cloud.appsportfolio.jsf.architecture.beans.StorageAccountBean]"
"Invalid Context Code - APP"
JbossLogFile
2016-06-03 00:19:52,612 -0500 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 3) JBAS014134: EJB Invocation failed on component GraBmsDataLoaderEjbIfc for method public abstract void com.gravitant.bms.common.dataload.GraBmsDataLoaderEjbIfc.loadVMTemplates(java.lang.String,java.lang.String,java.lang.String): javax.ejb.EJBException: com.gravitant.bts.bms.exception.GraException: Display Message:Transaction commit failed -
2016-06-03 00:20:10,809 -0500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (EJB default - 4) Duplicate entry '9db562c525e942698c605df2f0c9b26a__FreeBSD10_3-2016-06-02::unreco' for key 'UQ_graresourcetemplate$tmpId_prv_usrGrpId'
2016-06-03 00:20:10,824 -0500 ERROR [com.gravitant.bts.bms.transaction.BTSTransaction] (EJB default - 4) BmsBaseTransaction:Commit()- Transaction commit failed
2016-06-03 00:20:11,001 -0500 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 4) JBAS014134: EJB Invocation failed on component GraBmsDataLoaderEjbIfc for method public abstract void com.gravitant.bms.common.dataload.GraBmsDataLoaderEjbIfc.loadVMTemplates(java.lang.String,java.lang.String,java.lang.String): javax.ejb.EJBException: com.gravitant.bts.bms.exception.GraException: Display Message:Transaction commit failed -
2016-06-03 00:31:56,730 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-10) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
2016-06-03 00:52:01,379 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-1) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
2016-06-03 01:11:49,938 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-10) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
2016-06-03 01:41:59,942 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-1) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
2016-06-03 02:02:04,783 -0500 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[Faces Servlet]] (http-/10.200.212.143:8081-1) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: javax.faces.application.ViewExpiredException: viewId:/appsportfolio-main.jsf - View /appsportfolio-main.jsf could not be restored.
2016-06-03 02:11:57,211 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-1) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
2016-06-03 02:22:02,739 -0500 ERROR [org.picketlink.identity.federation] (http-/10.200.212.143:8081-10) PLFED000263: Service Provider could not handle the request.: java.lang.IllegalArgumentException: PLFED000132: No assertions in reply from IDP
201
什麼,我試圖做的是非常簡單的,我使用這個error_dict文件中的每個已知錯誤來匹配在這種情況下,如果我發現S的一部分我的JBoss的日誌文件從jboss日誌文件中打印該行,然後從jboss日誌文件中抽出該行。
非常相似,我可以實現它使用記事本++像標記所有行,然後刪除書籤將執行抽拉操作。非常類似我試圖實施過在Python代碼是如下
def MatchCountYankerrors():
ferrorrepo = errorrepopath
conclufile = os.path.join(Decompressfilepath,(appservername+'conclusion'))
ferrorfile = open(ferrorrepo)
confile = open(conclufile)
output = []
for errlines in ferrorfile: #Pick each line from error_dict
c = 0
for eachconline in confile:#pick each line from Jboss log
#if re.search(errlines,eachconline,re.M|re.I):
newerrliens = errlines.strip().split() #error_dict file each line strip and spilit
neweachconline = eachconline.strip().split() #Jbosslog file each line strip and spliting
if newerrliens in neweachconline:
print neweachconline