Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I am attempting to get a log output from the displayLogs() command and I have trying to do this within the WLST Interpreter. I get the following error which is "NameError: displayLogs" I am able to perform other commands such as domainRuntime() and a number of others, but this one seems to be outside the realm. Do I need to run it with some sort of classes in the classpath when running it? Any help would be appreciated.

The source code that I am using below:

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();
    }
}
share|improve this question

1 Answer 1

up vote 1 down vote accepted

UPDATE


Everything you are looking for lives in:

<install dir>/oracle_common/common/wlst

A simple grep -R displayLogs * returned the python module you need:

<install dir>/oracle_common/common/wlst/oracle-logging.py

You will need to include the jars that script needs on your classpath, specifically the logging jar ojdl.jar found under <install dir>/oracle_common/modules/oracle.odl

The above information was found by comparing the scripts below (I am using 10.3.6):


This script <install dir>/wlserver_10.3/common/bin/wlst.sh fails with:

wls:/offline> listLogs()
Traceback (innermost last):
  File "<console>", line 1, in ?
NameError: listLogs

This script <install dir>/oracle_common/common/bin/wlst.sh succeeds (and has many more options than the script above) :

wls:/offline> listLogs()
Not connected to a Weblogic server. Connect to a Weblogic server first.

Make sure you have all the same jars and properties set as the second script does.

share|improve this answer
    
I understand that it's likely a JAR that needs to be included, but however I am failing to see which one specifically that is. – hdost Jan 23 at 21:32
    
Updated with the python script you need – Display Name is missing Jan 23 at 21:51
    
I am using 12.1.3 but I figured it out needed to run the python file interpreter.execfile("ORACLE_HOME/oracle_common/common/wlst/OracleODL.py"); – hdost Jan 26 at 16:54
    
What if there is no OracleODL.py file under the wlst directory? – Carmen Cojocaru Jun 12 at 14:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.