⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.java~4~

📁 短信网关发送接受平台。
💻 JAVA~4~
字号:
package smscenter;import java.io.*;        /**         * <p>Title: sms_statistics</p>         * <p>Description: InHand XMLCenter 短信服务平台计费统计程序</p>         * <p>Copyright: Copyright (c) 2002</p>         * <p>Company: 北京映翰通网络技术有限公司</p>         * @author rjz@inhand.com.cn         * @version 1.0         */        public class Log{                private String root;                private PrintWriter out;                private FileWriter fout;                private String today;                public Log() {                        this.today=Utility.getDateString();                        createLog();                }                private void createLog(){                        String fileName="..\\log\\XMLRouter."+this.today+".log.xml";                        //String fileName=Utility.getDateString()+".log.xml";                        //Config.mail_fileAffix.add(fileName);                        try{                                File file=new File(fileName);                                if (file.exists()){                                        file.renameTo(new File("..\\log\\XMLRouter."+this.today+"@"+Utility.getTimeStr()+".log.xml"));                                        file=new File("..\\log\\XMLRouter."+this.today+".log.xml");                                }                                this.root="log";                                fout=new FileWriter(file);                                this.out=new PrintWriter(fout);                                this.out.println("<?xml version=\"1.0\" encoding=\"gb2312\"?>");                                this.out.println("<"+root+" date=\""+Utility.getDateString()+"\">");                                this.out.flush();                        }catch(IOException ioe){                                ioe.printStackTrace();                        }                }//                public synchronized void log(String content){//                        try{//                                if (!this.today.equalsIgnoreCase(Utility.getDateString())){//                                        this.close();//                                        this.today=Utility.getDateString();//                                        this.createLog();//                                }//                                XMLElement element=new XMLElement("log-content",content);//                                XMLAttribute attribute=new XMLAttribute("time",Utility.getTimeString());//                                element.addAttribute(attribute);//                                this.out.println(element.toString());//                                this.out.flush();//                                //this.notifyAll();//                        }catch(Exception ie){//                                ie.printStackTrace();//                        }//                }//                public synchronized void log(Exception e,String content){//                        try{//                                if (!this.today.equalsIgnoreCase(Utility.getDateString())){//                                        this.close();//                                        this.today=Utility.getDateString();//                                        this.createLog();//                                }//                                XMLTag tag=new XMLTag("log-content");//                                XMLAttribute attribute=new XMLAttribute("time",Utility.getTimeString());//                                XMLElement element=new XMLElement("Exception",content);//                                XMLAttribute exName=new XMLAttribute("name",e.getMessage());//                                element.addAttribute(exName);//                                tag.add(attribute);//                                tag.add(element);//                                this.out.println(tag.toString());//                                this.out.flush();//                                //this.notifyAll();//                        }catch(Exception ie){//                                ie.printStackTrace();//                        }//                }//                public synchronized void log(Exception e){//                        try{//                                if (!this.today.equalsIgnoreCase(Utility.getDateString())){//                                        this.close();//                                        this.today=Utility.getDateString();//                                        this.createLog();//                                }//                                XMLTag tag=new XMLTag("log-content");//                                XMLAttribute attribute=new XMLAttribute("time",Utility.getTimeString());//                                XMLElement element=new XMLElement("Exception");//                                XMLAttribute exName=new XMLAttribute("name",e.getMessage());//                                element.addAttribute(exName);//                                tag.add(attribute);//                                tag.add(element);//                                this.out.println(tag.toString());//                                this.out.flush();//                                //this.notifyAll();//                        }catch(Exception ie){//                                ie.printStackTrace();//                        }//                }//                public synchronized void log(String from,String actType,String content){//                        try{//                                if (!this.today.equalsIgnoreCase(Utility.getDateString())){//                                        this.close();//                                        this.today=Utility.getDateString();//                                        this.createLog();////                                }//                                XMLTag tag=new XMLTag("log-content");//                                XMLAttribute attribute=new XMLAttribute("time",Utility.getTimeString());//                                XMLElement element=new XMLElement("Data_Item",content);//                                XMLAttribute exName=new XMLAttribute("source",from);//                                element.addAttribute(exName);//                                XMLAttribute act=new XMLAttribute("type",actType);//                                element.addAttribute(act);//                                tag.add(attribute);//                                tag.add(element);//                                this.out.println(tag.toString());//                                this.out.flush();//                                //this.notifyAll();//                        }catch(Exception ie){//                                ie.printStackTrace();//                        }//                }//                public void close(){//                        try {//                                ServiceInfo serviceInfo=null;//                                String content="<log_content type=\"sum\" time=\""+Utility.getTimeString()+"\"><statistics><total_mt>"+Config.mt_recorder_number+"</tota_mt><total_mo>"+Config.mo_recorder_number+"</total_mo>";//                                for (int i=0;i<Config.subcode_item.size();i++){//                                        serviceInfo=(ServiceInfo)Config.subcode_item.elementAt(i);//                                        content+="<module id=\""+serviceInfo.id+"\"><mt>"+serviceInfo.getMt()+"</mt><mo>"+serviceInfo.getMo()+"</mo></module>";//                                }//                                for (int i=0;i<Config.service_id_item.size();i++){//                                        serviceInfo=(ServiceInfo)Config.service_id_item.elementAt(i);//                                        content+="<module id=\""+serviceInfo.id+"\"><mt>"+serviceInfo.getMt()+"</mt><mo>"+serviceInfo.getMo()+"</mo></module>";//                                }//                                content+="</statistics></log_content>";//                                out.println(content);//                                out.println("</"+this.root+">");//                                out.close();//                                this.fout.close();//                        }catch(IOException ioe){//                                ioe.printStackTrace();//                        }//                }                public static void main(String[] args) {                        Log log1 = new Log();//                        log1.log(new IOException("dfadsfads\r\nfdsalaksdjfalskdf"),"his");//                        log1.log("dfsdkfladsf");//                        log1.log("dfjsakdlasdl");//                        try {//                               Thread.sleep(3000);//                        }catch(Exception e){//                                e.printStackTrace();//                        }//                        log1.close();//                        log1.log("dfasdfasdssd");                }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -