Gaurav Kumar
Gaurav Kumar

Reputation: 1091

System.out.println printing on Server

Using eclipse :

When we normally sysout anything in a java file, it prints at the eclipse console but when our application is deployed on Jboss then sysout prints the value at Server console and server logs. What is it, that makes this change?

For eg: In a standalone normal Java Program

System.out.println("Java is Wonderful") prints on eclipse console

But if i write the same sentence in a java file i.e. a part of a web application and that application is deployed on JBoss then the value is printed on JBoss console and server logs.

What i know is "out" refers to system console so if i sysout anything it should write to system's console. Then why in case of web application deployed on JBoss it write on Server console.

Upvotes: 1

Views: 2843

Answers (2)

Stephen C
Stephen C

Reputation: 718926

The value of System.out starts out as the "standard output" stream for the JVM that is running the application.

  • When you run an application within Eclipse, Eclipse has used System.setOut(...) to a stream that writes to the Eclipse console.

  • When you launch a JVM from Eclipse, that JVM's System.out will start out referring back to the Eclipse console. The application in the JVM could then change it using System.setOut(...).

  • When you launch a JVM from the command line, JVM's System.out will start out referring back to the shell's console.

  • For something like JBoss, it is likely that the launch script (or native launcher) will change the standard output stream before it launches the application. It should be documented somewhere ...


So to find out exactly what is going on, you will need to look at how you are launching JBoss.

But there is nothing particularly mysterious about it.

Upvotes: 2

Vladimir
Vladimir

Reputation: 76

Your server's start script probably contains something like ...> stdout.txt 2> stderr.txt or ...> allout.txt 2>&1. It redirects standart IO in unix-like opearating systems. Other operating systems have similar commands.

Upvotes: 0

Related Questions