excel - I need to convert a log file into an XSL sheet -
i need convert log file xsl sheet- format of log file looks like-
73445971 [webcontainer : 3] error error.com.xyz.cat.csd.datarqst.model.datarequestcollection - {event id=9248285763 | time=2015-05-25-00.22.11.822000 | event type=error | request id=_3acunq3qj_g4omm7z3dmcs | lifecycle=qa | application id=xyz | application version=2015-05-21-015732 | host name=lzbita18 | server instance=18_cl1_web20_qa_m1 | client descriptor=sxyz | user id=@1224 | request descriptor=https://abcb04.xyz.com/csd/alert.do | session id=_3acunq3qj_g4omm7z3dmcs | session create timestamp=2015-05-25-00.19.03.326000 | global session id=231cf811:_3acunq3qj_g4omm7z3dmcs | remote address=10.230.9.164 | message=missing provision data request: | method=getdatarequest() | severity=error} 77379848 [webcontainer : 3] error error.com.xyz.cat.csd.connectivity.connectivityexception - {event id=1823361457 | time=2015-05-25-01.27.45.697000 | event type=error | request id=mkhel__utfhau8qoshrqhhp | lifecycle=qa | application id=xyz | application version=2015-05-21-015732 | host name=lzbita18 | server instance=18_cl1_web20_qa_m1 | client descriptor=zyx | user id=1225 | request descriptor=https://abc04.xyz.com/csd/clntprvsn.do | session id=mkhel__utfhau8qoshrqhhp | session create timestamp=2015-05-25-01.26.22.442000 | global session id=0:mkhel__utfhau8qoshrqhhp | remote address=10.229.14.121 | message=exception in thread module: 20, adapter: com.xyz.cat.csd.connectivity.adapter.webserviceadapter: exceeded max time. | method=com.xyz.cat.csd.connectivity.abstractdao.adapterexception(abstractdao.java:423) | severity=error | stack trace=com.xyz.cat.csd.connectivity.connectivityexception: exception in thread module: 20, adapter: com.xyz.cat.csd.connectivity.adapter.webserviceadapter: exceeded max time. @ com.xyz.cat.csd.connectivity.abstractdao.adapterexception(abstractdao.java:423) @ com.xyz.cat.csd.connectivity.abstractdao.process(abstractdao.java:313) ... 33 more}
column separated on basis of pipe delimiter '|'
what looking format value should in defined column , value of stack trace should in 1 column in multiple line , end (om.xyz.cat.csd.connectivity.abstractdao.process(abstractdao.java:313) ... 33 more} ) below code trying use below code-
class openl implements actionlistener { public void actionperformed(actionevent e) { final jfilechooser c = new jfilechooser(); // demonstrate "open" dialog: int rval = c.showopendialog(filechoosertest.this); if (rval == jfilechooser.approve_option) { filename.settext(c.getselectedfile().getname()); dir.settext(c.getcurrentdirectory().tostring());
try { file logfile = c.getselectedfile(); fileinputstream fstream = new fileinputstream(logfile); bufferedreader br = new bufferedreader(new inputstreamreader(fstream)); string strline; stringbuffer sb = new stringbuffer(); sb .append("event id, time, event type, request id, lifecycle, application id, application version, host name, " + "server instance, client descriptor, user id, request descriptor, session id, session create timestamp, global session id, remote, address, message, method, severity, stack trace "); sb.append("\n"); while ((strline = br.readline()).isempty() || (strline = br.readline()) != null || !(strline = br.readline()).equals("")) { if (strline.contains("{")) { string str = strline.substring(strline.indexof("{") + 1, strline.length() - 1); string[] tokens = str.split("\\|"); (string token : tokens) { string value = token.substring(token.indexof("=") + 1, token .length()); sb.append(value); sb.append(","); } } sb.append("\n"); } br.close(); writer writer = null; try { writer = new bufferedwriter(new outputstreamwriter(new fileoutputstream("c:/users/xyz/desktop/cspro.csv"), "utf-8")); writer.write(sb.tostring()); } catch (ioexception ex) { // report } { try { writer.close(); } catch (exception ex) { } } } catch (exception e1) { e1.printstacktrace(); } } if (rval == jfilechooser.cancel_option) { filename.settext("you pressed cancel"); dir.settext(""); } } }
Comments
Post a Comment