Browse Source

Pull request #7103: KERNEL-9687 log4j版本升级-设计器配合

Merge in DESIGN/design from ~HADES/design:KERNEL-9687 to feature/x

* commit 'b7d61b5196cdf01ab27be87c2cae39eefe8a2235':
  KERNEL-9687 log4j版本升级-设计器配合
feature/x
Dylan.Liu 3 years ago
parent
commit
be2644be66
  1. 15
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 5
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 42
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  4. 22
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  5. 41
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  6. 27
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java
  7. 47
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  8. 25
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  9. 11
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  10. 4
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

15
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -53,7 +53,8 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.apache.log4j.FileAppender; import com.fr.third.apache.logging.log4j.core.appender.FileAppender;
import com.fr.third.apache.logging.log4j.core.layout.PatternLayout;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
@ -324,18 +325,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!new File(fileName).exists()) { if (!new File(fileName).exists()) {
StableUtils.makesureFileExist(new File(fileName)); StableUtils.makesureFileExist(new File(fileName));
} }
LogHandler handler = new LogHandler<FileAppender>() { LogHandler<FileAppender> handler = new LogHandler<FileAppender>() {
final FileAppender appender = new FileAppender( final FileAppender appender = FileAppender.newBuilder().
new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"), setName(FileAppender.class.getSimpleName()).
fileName setLayout(PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n").build()).
); withFileName(fileName).build();
@Override @Override
public FileAppender getHandler() { public FileAppender getHandler() {
return appender; return appender;
} }
}; };
handler.getHandler().start();
FineLoggerFactory.getLogger().addLogAppender(handler); FineLoggerFactory.getLogger().addLogAppender(handler);
} catch (SecurityException e) { } catch (SecurityException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

5
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -29,7 +29,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
@ -45,14 +44,12 @@ import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.sun.javafx.tk.FileChooserType;
import javafx.stage.FileChooser;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;

42
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java

@ -1,41 +1,41 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.log4j.AppenderSkeleton; import com.fr.third.apache.logging.log4j.core.Filter;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.core.Layout;
import com.fr.third.apache.log4j.spi.LoggingEvent; 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; import java.util.Date;
/** /**
* Created by Administrator on 2017/7/18 0018. * Created by Administrator on 2017/7/18 0018.
*/ */
public class DesignerLogAppender extends AppenderSkeleton { public class DesignerLogAppender extends AbstractAppender {
public DesignerLogAppender() { protected DesignerLogAppender(String name, Filter filter,
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
} }
protected void append(LoggingEvent event) { public static DesignerLogAppender createDesignerLogAppender() {
this.subAppend(event); 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);
} }
public boolean requiresLayout() { @Override
return true; public void append(LogEvent event) {
} this.subAppend(event);
public synchronized void close() {
if (this.closed) {
return;
} }
this.closed = true;
}
public void subAppend(LoggingEvent event) { public void subAppend(LogEvent event) {
synchronized (DesignerLogHandler.getInstance()) { synchronized (DesignerLogHandler.getInstance()) {
Level level = event.getLevel(); Level level = event.getLevel();
String msg = this.layout.format(event); String msg = (String) this.toSerializable(event);
DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date()); DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date());
} }
} }

22
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -9,10 +9,9 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.ActionMap; import javax.swing.ActionMap;
import javax.swing.InputMap; import javax.swing.InputMap;
@ -128,7 +127,7 @@ public class DesignerLogHandler {
JPopupMenu jPopupMenu = new JPopupMenu(); JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); int logLevelInt = Log4jConfig.getInstance().getRootLevel().intLevel();
if (logLevelInt <= DesignerLogger.INFO_INT) { if (logLevelInt <= DesignerLogger.INFO_INT) {
jPopupMenu.add(showInfo); jPopupMenu.add(showInfo);
jPopupMenu.add(showError); jPopupMenu.add(showError);
@ -240,23 +239,22 @@ public class DesignerLogHandler {
return resultPane; return resultPane;
} }
public void printStackTrace(LoggingEvent event) { public void printStackTrace(LogEvent event) {
int intLevel = event.getLevel().toInt(); int intLevel = event.getLevel().intLevel();
Date date = new Date(event.getTimeStamp()); Date date = new Date(event.getTimeMillis());
ThrowableInformation information = event.getThrowableInformation();
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} }
} }
public void printStackTrace(String message, Level level, Date date) { public void printStackTrace(String message, Level level, Date date) {
int intLevel = level.toInt(); int intLevel = level.intLevel();
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(message, intLevel, date); printMessage(message, intLevel, date);
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {

41
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java

@ -1,26 +1,25 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
/** /**
* 设计器日志记录 * 设计器日志记录
*/ */
public class DesignerLogger { public class DesignerLogger {
public static final int INFO_INT = Level.INFO.toInt(); public static final int INFO_INT = Level.INFO.intLevel();
public static final int ERROR_INT = Level.ERROR.toInt(); public static final int ERROR_INT = Level.ERROR.intLevel();
public static final int WARN_INT = Level.WARN.toInt(); public static final int WARN_INT = Level.WARN.intLevel();
/** /**
* 记录LoggingEvent对象 * 记录LoggingEvent对象
* *
* @param event * @param event
*/ */
public static void log(LoggingEvent event) { public static void log(LogEvent event) {
if (event == null) { if (event == null) {
return; return;
} }
@ -30,29 +29,27 @@ public class DesignerLogger {
public enum LogParser { public enum LogParser {
DEFAULT(-1) { DEFAULT(-1) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
} }
}, },
INFO(Level.INFO.toInt()) { INFO(Level.INFO.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
FineLoggerFactory.getLogger().info(event.getRenderedMessage()); FineLoggerFactory.getLogger().info(event.getMessage().getFormattedMessage());
} }
}, },
WARN(Level.WARN.toInt()) { WARN(Level.WARN.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
ThrowableInformation information = event.getThrowableInformation(); FineLoggerFactory.getLogger().warn(event.getMessage().getFormattedMessage(), event.getThrown());
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable());
} }
}, },
ERROR(Level.ERROR.toInt()) { ERROR(Level.ERROR.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
ThrowableInformation information = event.getThrowableInformation(); FineLoggerFactory.getLogger().error(event.getMessage().getFormattedMessage(), event.getThrown());
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable());
} }
}; };
private int level; private int level;
@ -65,8 +62,8 @@ public class DesignerLogger {
return level; return level;
} }
public static LogParser parse(LoggingEvent event) { public static LogParser parse(LogEvent event) {
int intLevel = event.getLevel().toInt(); int intLevel = event.getLevel().intLevel();
for (LogParser logParser : values()) { for (LogParser logParser : values()) {
if (logParser.getLevel() == intLevel) { if (logParser.getLevel() == intLevel) {
return logParser; return logParser;
@ -76,7 +73,7 @@ public class DesignerLogger {
} }
public void log(LoggingEvent event) { public void log(LogEvent event) {
} }
} }
} }

27
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java

@ -0,0 +1,27 @@
package com.fr.design.mainframe.loghandler;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.logging.log4j.core.impl.Log4jLogEvent;
import com.fr.third.apache.logging.log4j.message.SimpleMessage;
/**
* 兼容log4j1和2之间logEvent之间的转换
*
* @author hades
* @version 11.0
* Created by hades on 2021/12/9
*/
public class LogEventConverter {
public static LogEvent convert(LoggingEvent loggingEvent) {
SimpleMessage message = new SimpleMessage(loggingEvent.getRenderedMessage());
return Log4jLogEvent.newBuilder().
setMessage(message).
setLevel(Level.getLevel(loggingEvent.getLevel().toString())).
build();
}
}

47
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -4,6 +4,13 @@ import com.fr.base.io.IOFile;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
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 com.fr.web.session.SessionLocalManager; import com.fr.web.session.SessionLocalManager;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -12,22 +19,20 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.stable.web.SessionProvider; import com.fr.stable.web.SessionProvider;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.apache.log4j.AppenderSkeleton;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.web.core.SessionPoolManager; import com.fr.web.core.SessionPoolManager;
import com.fr.web.core.TemplateSessionIDInfo; import com.fr.web.core.TemplateSessionIDInfo;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable;
/** /**
* 收集设计器报错信息的appender. * 收集设计器报错信息的appender.
* <p> * <p>
* Created by Administrator on 2017/7/24 0024. * Created by Administrator on 2017/7/24 0024.
*/ */
public class ErrorInfoLogAppender extends AppenderSkeleton { public class ErrorInfoLogAppender extends AbstractAppender {
private static final int ERROR_LEN = 8; private static final int ERROR_LEN = 8;
private static final int ERROR_STACK_TRACE = 15; private static final int ERROR_STACK_TRACE = 15;
@ -38,16 +43,23 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
private String uuid; private String uuid;
private String activekey; private String activekey;
public ErrorInfoLogAppender() { protected ErrorInfoLogAppender(String name, Filter filter,
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
this.username = envManager.getDesignerLoginUsername(); this.username = envManager.getDesignerLoginUsername();
this.uuid = envManager.getUUID(); this.uuid = envManager.getUUID();
this.activekey = envManager.getActivationKey(); this.activekey = envManager.getActivationKey();
} }
protected void append(LoggingEvent event) { public static ErrorInfoLogAppender createErrorLogAppender() {
return new ErrorInfoLogAppender(ErrorInfoLogAppender.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); this.subAppend(event);
} }
@ -55,19 +67,12 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
return true; return true;
} }
public synchronized void close() {
if (this.closed) {
return;
}
this.closed = true;
}
public void subAppend(LoggingEvent event) { public void subAppend(LogEvent event) {
Level level = event.getLevel(); Level level = event.getLevel();
// 只分析上传记录error以上的. // 只分析上传记录error以上的.
if (level.isGreaterOrEqual(Level.ERROR)) { if (level.isMoreSpecificThan(Level.ERROR)) {
String msg = this.layout.format(event); String msg = (String) this.toSerializable(event);
// 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错. // 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错.
String templateid = readTemplateID(); String templateid = readTemplateID();
String logid = readLogID(msg); String logid = readLogID(msg);
@ -80,13 +85,13 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
} }
} }
private String readStackTrace(LoggingEvent event) { private String readStackTrace(LogEvent event) {
String[] s = event.getThrowableStrRep(); StackTraceElement[] s = event.getThrown() == null ? null : event.getThrown().getStackTrace();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (s != null) { if (s != null) {
int len = Math.min(s.length, ERROR_STACK_TRACE); int len = Math.min(s.length, ERROR_STACK_TRACE);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
sb.append(s[i]).append("\n"); sb.append(s[i].toString()).append("\n");
} }
} }
return sb.toString(); return sb.toString();

25
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -44,30 +44,35 @@ public class ErrorInfoUploader {
//单次发送的错误信息最大条数 //单次发送的错误信息最大条数
private static final int MAX_ITEMS = 200; private static final int MAX_ITEMS = 200;
private static LogHandler<ErrorInfoLogAppender> logHandler;
static { static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override @Override
public void envChanged() { public void envChanged() {
FineLoggerFactory.getLogger().addLogAppender(new LogHandler<ErrorInfoLogAppender>() { if (logHandler != null) {
private ErrorInfoLogAppender errorInfoLogAppender = new ErrorInfoLogAppender(); logHandler.getHandler().stop();
FineLoggerFactory.getLogger().removeLogAppender(logHandler);
@Override logHandler.getHandler().start();
public ErrorInfoLogAppender getHandler() { FineLoggerFactory.getLogger().addLogAppender(logHandler);
return errorInfoLogAppender;
} }
});
} }
}); });
} }
private ErrorInfoUploader() { private ErrorInfoUploader() {
FineLoggerFactory.getLogger().addLogAppender(new LogHandler<ErrorInfoLogAppender>() { logHandler = new LogHandler<ErrorInfoLogAppender>() {
private final ErrorInfoLogAppender errorInfoLogAppender = ErrorInfoLogAppender.createErrorLogAppender();
@Override @Override
public ErrorInfoLogAppender getHandler() { public ErrorInfoLogAppender getHandler() {
return new ErrorInfoLogAppender(); return errorInfoLogAppender;
} }
}); };
logHandler.getHandler().start();
FineLoggerFactory.getLogger().addLogAppender(logHandler);
} }
public static ErrorInfoUploader getInstance() { public static ErrorInfoUploader getInstance() {

11
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -11,6 +11,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogger; import com.fr.design.mainframe.loghandler.DesignerLogger;
import com.fr.design.mainframe.loghandler.LogEventConverter;
import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil; import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.mainframe.toast.ToastMsgDialog; import com.fr.design.mainframe.toast.ToastMsgDialog;
@ -23,6 +24,7 @@ import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.org.apache.http.client.config.RequestConfig; import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.client.methods.HttpGet;
@ -148,7 +150,14 @@ public class DesignerSocketIO {
public void call(Object... objects) { public void call(Object... objects) {
if (ArrayUtils.isNotEmpty(objects)) { if (ArrayUtils.isNotEmpty(objects)) {
try { try {
LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); Object obj = SerializerHelper.deserialize((byte[]) objects[0]);
// 兼容下老版本服务器
LogEvent event;
if (obj instanceof LoggingEvent) {
event = LogEventConverter.convert((LoggingEvent) obj);
} else {
event = (LogEvent) obj;
}
DesignerLogger.log(event); DesignerLogger.log(event);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

4
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -191,18 +191,20 @@ public class DesignerActivator extends Activator implements Prepare {
private void loadLogAppender() { private void loadLogAppender() {
logHandler = new LogHandler<DesignerLogAppender>() { logHandler = new LogHandler<DesignerLogAppender>() {
final DesignerLogAppender logAppender = new DesignerLogAppender(); final DesignerLogAppender logAppender = DesignerLogAppender.createDesignerLogAppender();
@Override @Override
public DesignerLogAppender getHandler() { public DesignerLogAppender getHandler() {
return logAppender; return logAppender;
} }
}; };
logHandler.getHandler().start();
FineLoggerFactory.getLogger().addLogAppender(logHandler); FineLoggerFactory.getLogger().addLogAppender(logHandler);
} }
private void unloadLogAppender() { private void unloadLogAppender() {
if (logHandler != null) { if (logHandler != null) {
logHandler.getHandler().stop();
FineLoggerFactory.getLogger().removeLogAppender(logHandler); FineLoggerFactory.getLogger().removeLogAppender(logHandler);
} }
} }

Loading…
Cancel
Save