• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving Java Console output to file

 
John McParland
Ranch Hand
Posts: 92
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I was wondering if there is a way to save the output displayed on the Java console to a file? Unfortunately for the situation I'm testing updating the code is not an option so it would have to be a setting or something I can change.

A web search only ever seems to reveal code changes to make

John
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java console meaning JConsole, or meaning the OS console window (CMD.EXE) ? If it's the latter, the answer varies by OS, of course, but generally there's a way of cutting and pasting out of that window and into a file. For example, in Windows, if you enable "Smart Edit" in the Properties tab for your consoles, then you can rightclick-drag across text to select it. Furthermore, the same Properties wizard lets you set the scrollback of the window so that lines that scroll off the screen don't disappear.

If you mean JConsole, screenshots are about the best you can do, I think.
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use > in the console to redirect the standard output, use 2> to redirect the standard error output:
To merge the standard output and error output redirect the error output to the standard output (it must be put after the standard output redirection or it will redirect to the old standard output - the console):
 
John McParland
Ranch Hand
Posts: 92
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,

thanks for the swift reply.

The console I mean is the one which is shown when you web-start an application (picture attached). Unfortunately a screenshot isn't possible in this case because I'm trying to get some logging from my application at the moment of shutdown (when unfortunately the Java console dissapears also).

To do the same thing (on a windows system), go to control panel -> switch to classic view -> java -> advanced tab -> console -> show console.
Launch a webstarted application (I chose BorderDemo from http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html#table)

John
javaconsole.JPG
[Thumbnail for javaconsole.JPG]
Java console
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That "Copy" button looks useful -- copy, then paste into a file in Notepad.
 
John McParland
Ranch Hand
Posts: 92
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to capture logging at the point my application exits. This exits the JVM too (System.exit()) and the console then dies so I do not have time to do the copy.

A way to make the console persist after the application which started it would be helpful too if it is not possible to have it automatically written to a file somewhere.

Regards,

John
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your logging options?
 
Frank Nguyen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The log file is saved as "plugin#####.log" in C:\Documents and Settings\[your login]\Application Data\Sun\Java\Deployment\log.
java console log file.PNG
[Thumbnail for java console log file.PNG]
 
Frank Nguyen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A new plugin log file will be generated every time you open a new browser. You just need to get the latest one, read lines, and collect your outputs or any exceptions.

Frank
 
Akhash Ramamurthy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank Nguyen wrote:A new plugin log file will be generated every time you open a new browser. You just need to get the latest one, read lines, and collect your outputs or any exceptions.

Frank


Thanks Frank. Saved me a lot of time for me.

Akhash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic