You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
43 lines
1.6 KiB
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()); |
|
} |
|
} |
|
} |
|
|
|
|