where's the System.out.println output or log4j console output?

trand2trand2 Posts: 8

I am invoking a simple helloworld Java class in SOATest using the Extension Tool. The method I'm running is behaving fine, except that I am unable to see the System.out or the log4j output (configured to output to console) from my Java class. I can see the output in console just fine when running the Java class outside of SOATest perspective.

I am currently using Application.showMessage("hello world"); to output to SOATest console, and that works fine.

I feel like i'm missing something obvious here. Please halp!



  • benken_parasoftbenken_parasoft Posts: 935 ✭✭✭
    edited July 2017

    Your java class executes in the same JVM as SOAtest. To see messages printed to STDOUT/STDERR from the JVM, you can start the soatest exe with the -consolelog argument.

    Concerning log4j, you can configure log4j to do what you want. Perhaps you want to configure a console appender, for example. Typically you configure things like appenders and log levels on a per-package basis. This could be done programmatically or from an external config file. Really, you would need to refer to the docs on apache.org for how to configure log4j.

    Concerning Application.showMessage(String), this is the correct way to print messages to the SOAtest Console view in the workbench. Whether you want to print messages to the SOAtest Console view with Application.showMessage() or to STDOUT/STDERR with System.out/err is your choice.

  • trand2trand2 Posts: 8

    I am able to configure log4j programmatically (as opposed to use the properties file). The code that sets up the log4j configs is located at the beginning of the method that is ran. This is a problem because I only need this code to run once, but it is running for each line of my datasource (causing inconsistent output). Is there a way to invoke a method once at the beginning of a test, then followed by the test iterations as determined by the datasource row?


  • benken_parasoftbenken_parasoft Posts: 935 ✭✭✭
    edited July 2017

    A setup test is typically used for things that should only be done once. You can add an Extension Tool as a setup test as opposed to a normal test. However, whether you add it as a setup test or a normal test you probably want it added to the parent suite, not the suite that is looping over data source rows.

  • trand2trand2 Posts: 8

    "you can start the soatest exe with the -consolelog argument"

    I am able to see the java console output with the -console argument in my Windows shortcut "Target" field. Any idea how to append its output to a txt file?

  • benken_parasoftbenken_parasoft Posts: 935 ✭✭✭
    edited July 2017

    To capture command line output from a process (SOAtest or otherwise) you can add something like >log.txt 2>&1 to the end of the command. For example, this could be soatest -consolelog >log.txt 2>&1. However, if you are on Windows (as opposed to Linux/Mac) this will only work if you start SOAtest the SOAtest UI with the eclipsec.exe (instead of soatest.exe) from the "Parasoft\Test\9.x" directory (for example, C:\Program Files\Parasoft\Test\9.10\eclipsec.exe).
    Other explanation on the web:

    Otherwise, if you are doing a command line run with soatestcli, then soatestcli will show you all STDOUT/STDERR by default. If you are using a build automation tool to run soatestcli (Jenkins, Bamboo, TeamCity, etc.) then such tools generally archive the console output automatically.

  • carldivincarldivin Posts: 1

    What is System.out.println

    System.out.println is a Java statement that prints the argument passed, into the System.out which is generally stdout.

    • System – is a final class in java.lang package. As per javadoc, “…Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array…“

    • out – is a static member field of System class and is of type PrintStream. Its access specifiers are public final. This gets instantiated during startup and gets mapped with standard output console of the host. This stream is open by itself immediately after its instantiation and ready to accept data.

    • println – is a method of PrintStream class. println prints the argument passed to the standard console and a newline. There are multiple println methods with different arguments (overloading). Every println makes a call to print method and adds a newline. print calls write() and the story goes on like that.

Sign In or Register to comment.