|
|
|
package com.fr.design.mainframe.loghandler;
|
|
|
|
|
|
|
|
import com.fr.third.apache.logging.log4j.Level;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.Filter;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.Layout;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.LogEvent;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.appender.AbstractAppender;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.config.Property;
|
|
|
|
import com.fr.third.apache.logging.log4j.core.layout.PatternLayout;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Administrator on 2017/7/18 0018.
|
|
|
|
*/
|
|
|
|
public class DesignerLogAppender extends AbstractAppender {
|
|
|
|
|
|
|
|
protected DesignerLogAppender(String name, Filter filter,
|
|
|
|
Layout<? extends Serializable> layout,
|
|
|
|
boolean ignoreExceptions,
|
|
|
|
Property[] properties) {
|
|
|
|
super(name, filter, layout, ignoreExceptions, properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DesignerLogAppender createDesignerLogAppender() {
|
|
|
|
return new DesignerLogAppender(DesignerLogAppender.class.getSimpleName(), null, PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n %throwable{0}").build(), false, Property.EMPTY_ARRAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void append(LogEvent event) {
|
|
|
|
this.subAppend(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void subAppend(LogEvent event) {
|
|
|
|
synchronized (DesignerLogHandler.getInstance()) {
|
|
|
|
Level level = event.getLevel();
|
|
|
|
String msg = (String) this.toSerializable(event);
|
|
|
|
DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|