首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WLSTInterpreter NameError: displayLogs中使用NameError()

在WLSTInterpreter NameError: displayLogs中使用NameError()
EN

Stack Overflow用户
提问于 2015-01-23 18:16:03
回答 1查看 1.5K关注 0票数 1

我正在尝试从displayLogs()命令获得一个日志输出,并且我已经尝试在WLST解释器中这样做。我得到了以下错误,即"NameError: displayLogs“,我能够执行其他命令,如domainRuntime()和许多其他命令,但这个命令似乎超出了范围。在运行它时,我需要使用类路径中的类来运行它吗?任何帮助都将不胜感激。

下面使用的源代码:

代码语言:javascript
复制
package wlst;
import weblogic.management.scripting.utils.WLSTInterpreter;
import org.python.util.InteractiveInterpreter;
import org.python.core.PyObject;

public class EmbeddedWLST
{
  static InteractiveInterpreter interpreter = null;
  EmbeddedWLST() {
    interpreter = new WLSTInterpreter();
  }

private static void connect() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("connect('USERNAME','PASSWORD','t3://HOSTANAME:PORT')");
    interpreter.exec(buffer.toString());
}

public static void main(String[] args) {
    new EmbeddedWLST();
    connect();
    PyObject cmo = interpreter.get("cmo");
    String command = getLogs();
    System.out.println("Executing Get Logs");
    interpreter.exec(command);
    System.out.println("Getting Output Object");
    PyObject output = interpreter.get("output");
    System.out.println(output.getClass());
    System.out.println(output);
  }

    private static String getLogs() {
        StringBuffer buf = new StringBuffer();
        buf.append( "output = displayLogs(returnData=1)\n" );
        return buf.toString();
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-23 19:23:17

更新

所有你想要的生活:

代码语言:javascript
复制
<install dir>/oracle_common/common/wlst

一个简单的grep -R displayLogs *返回了您需要的python模块:

代码语言:javascript
复制
<install dir>/oracle_common/common/wlst/oracle-logging.py

您需要在类路径上包含脚本所需的jar,特别是在<install dir>/oracle_common/modules/oracle.odl下找到的日志记录jar。

上述信息是通过比较以下脚本(我使用的是10.3.6)找到的:

此脚本<install dir>/wlserver_10.3/common/bin/wlst.sh在以下方面失败:

代码语言:javascript
复制
wls:/offline> listLogs()
Traceback (innermost last):
  File "<console>", line 1, in ?
NameError: listLogs

此脚本<install dir>/oracle_common/common/bin/wlst.sh成功(并且比上面的脚本有更多的选项):

代码语言:javascript
复制
wls:/offline> listLogs()
Not connected to a Weblogic server. Connect to a Weblogic server first.

确保设置了与第二个脚本相同的jars和属性。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28116196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档