我想使用deobfuscate选项配置远程日志记录服务。我知道默认情况下符号映射是在/ WEB-INF / deploy / MODULNAME / symbolMaps文件夹中生成的,GWT远程记录器实现(RemoteLoggingServiceImpl)使用StackTraceDeobfuscator,它需要symbolMaps目录才能工作。我认为RemoteLoggingServiceImpl应该自动设置symbolMaps目录的正确路径,但是在调试模式下我发现setSymbolMapsDirectory方法没有在RemoteLoggingServiceImpl上调用。要解决该问题,我使用“proxy”手动调用该方法:
public class ConfigurableRemoteLoggingServiceImpl extends RemoteLoggingServiceImpl {
@Override
public void init(final ServletConfig config) throws ServletException {
super.init(config);
final String symbolMapsDirectory = config.getInitParameter("symbolMapsDirectory");
setSymbolMapsDirectory(symbolMapsDirectory);
}
}
并在web.xml中
<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>pl.dandelite.empik.sdl.manager.server.service.ConfigurableRemoteLoggingServiceImpl</servlet-class>
<init-param>
<param-name>symbolMapsDirectory</param-name>
<param-value>C:/symbolMaps</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/sdlconsole/remote_logging</url-pattern>
</servlet-mapping>
并在编译期间使用-extra parametr
定义dir这个解决方案有效,但只有当我设置symbolMaps目录的绝对路径时,有点不切实际;)
现在我的问题是:在Tomcat上使用StackTraceDeobfuscator配置RemoteLoggingServiceImpl的正确方法是什么?
答案 0 :(得分:1)
以下是我设置符号目录的方法:
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
// Synchronized so that in a multi-module deployment, there are no conflicts.
synchronized (RemoteLoggingServiceImpl.class) {
// Initialize SLF$j bridge logging to redirect jul logs to slf4j. We remove any
// default loggers to ensure logging doesn't happen to stdout or stderr.
java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger("");
Handler[] handlers = rootLogger.getHandlers();
for (Handler handler : handlers) {
rootLogger.removeHandler(handler);
}
SLF4JBridgeHandler.install();
}
String moduleName = config.getInitParameter("module.name");
if (StringUtils.isBlank(moduleName)) {
_logger.error("No module name defined. Please set the module.name servlet init "
+ "parameter to point to the GWT module and enable extra symbolMaps at "
+ "/extra/<module name>/symbolMaps in the servlet context to facilitate "
+ "deobfuscation of stack traces.");
} else {
String path = config.getServletContext().getRealPath(
"/WEB-INF/deploy/" + moduleName + "/symbolMaps/");
if (path != null) {
setSymbolMapsDirectory(path);
}
} // end else.
}