这里假设以及在工程中配置好了sap相关库文件。
定义日志变量
private static final com.sap.tc.logging.Location location = com.sap.tc.logging.Location.getLocation(xxx.class);
这里的xxx.class
就是当前变量所在类。
使用日志输出
SimpleLogger.log(Severity.INFO, Category.SYS_SERVER, location, "xxx", jsonString);
这里的xxx
就是sap日志输出的相关标识key,这样就可以去sap服务器的web日志界面看日志了。
查日志
使用管理员账号,登录sap的startPage页面
→System Information→Home→Troubleshooting→Logs and Traces→Log Viewer→View→Open View→SAP Logs,就可以查看日志了。