long
2023-09-02 e379948bb83ebcc9ce0c467a7b970f74bc00e9a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cn.stylefeng.guns.plcserver.tool;
 
import org.apache.log4j.Logger;
 
import java.io.PrintWriter;
import java.io.StringWriter;
 
 
public class LogUtil
{
    private static Logger log;
    
    static
    {
        log = Logger.getLogger(LogUtil.class);
    }
        
    /**
     *  
     * @title getTrace
     * @description 输出异常详细信息
     * @param t
     * @return String 
     * @author  ROC
     */
    public  String getTrace(Throwable t)
    {
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(stringWriter);
        t.printStackTrace(writer);
        StringBuffer buffer = stringWriter.getBuffer();
        return "抛出异常详细:"+buffer.toString();
    }
 
    
    /**
     * 输出标准日志
     */
    public void outputFinalLog (String startStr, String expStr,String endStr)
    {
        StringBuffer logStr = new StringBuffer();
        logStr.append(startStr);
        //logStr.append("\r\n");
        if (expStr != null)
        {
            logStr.append(expStr);
            //logStr.append("\r\n");
        }
        logStr.append(endStr);
        logStr.append("\r\n");
        log.info(logStr.toString());
    }
    
}