我正在尝试从displayLogs()命令获得一个日志输出,并且我已经尝试在WLST解释器中这样做。我得到了以下错误,即"NameError: displayLogs“,我能够执行其他命令,如domainRuntime()和许多其他命令,但这个命令似乎超出了范围。在运行它时,我需要使用类路径中的类来运行它吗?任何帮助都将不胜感激。
下面使用的源代码:
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();
}
}发布于 2015-01-23 19:23:17
更新
所有你想要的生活:
<install dir>/oracle_common/common/wlst一个简单的grep -R displayLogs *返回了您需要的python模块:
<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在以下方面失败:
wls:/offline> listLogs()
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: listLogs此脚本<install dir>/oracle_common/common/bin/wlst.sh成功(并且比上面的脚本有更多的选项):
wls:/offline> listLogs()
Not connected to a Weblogic server. Connect to a Weblogic server first.确保设置了与第二个脚本相同的jars和属性。
https://stackoverflow.com/questions/28116196
复制相似问题