4

我想使用 deobfuscate 选项配置远程日志记录服务。我知道默认情况下符号映射是在 /WEB-INF/deploy/MODULNAME/symbolMaps 文件夹中生成的,并且 GWT 远程记录器实现 (RemoteLoggingServiceImpl) 使用 StackTraceDeobfuscator,它需要 symbolMaps 目录才能工作。我认为 RemoteLoggingServiceImpl 应该自动设置符号映射目录的正确路径,但是在调试模式下我发现 setSymbolMapsDirectory 方法没有在 RemoteLoggingServiceImpl 上调用。为了解决这个问题,我使用“代理”手动调用该方法:

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 参数定义目录

该解决方案有效,但仅当我将绝对路径设置为 symbolMaps 目录时,这有点不切实际;)

现在我的问题是:在 Tomcat 上使用 StackTraceDeobfuscator 配置 RemoteLoggingServiceImpl 的正确方法是什么?

4

1 回答 1

2

这是我设置符号目录的方法:

@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.
}
于 2013-01-15T18:35:28.627 回答