先编写log4j自定义appdener,代码如下
package com.appender;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.spi.LoggingEvent;
public class SoapAppender extends AppenderSkeleton{
private String file = "";
public void setFile(String filedata){
file = filedata;
}
public String getFile(){
return file;
}
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean requiresLayout() {
// TODO Auto-generated method stub
return true;
}
@Override
protected void append(LoggingEvent event) {
// TODO Auto-generated method stub
Object obdata = hexToString(event.getMessage().toString());
LoggingEvent soaplogevent = new LoggingEv