title: Groovy-script in jenkins println output disappears when called inside class environment
body: <p>The output from println from within a class function is lost.</p>
  
  <p>An example script (outputclass.groovy):</p>
  
  <pre><code>class OutputClass
  {
      OutputClass()
      {
          println("Inside class")  // This will not show in the console
      }
  }
  
  println("Outside class")  // Only this is shown in the console
  output = new OutputClass()
  </code></pre>
  
  <p>I use Jenkins CLI to execute the groovy script</p>
  
  <pre><code>java -jar ..\jenkins-cli.jar -s JENKINS_SERVER_URL groovy outputclass.groovy
  </code></pre>
  
  <p>It only outputs this:</p>
  
  <blockquote>
    <p>Outside class</p>
  </blockquote>
  
  <p>It seems like the class inmplicitly uses println from System.out.println, and System.out is directed to the log files, but the println outside the class is using something else, which is outputted in the script console. The following code shows the behavior.</p>
  
  <pre><code>System.out.println("First")
  println("Second")
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>Second</p>
  </blockquote>
  
  <p>How do I explicitly set the output device to output to the Jenkins script console?</p>