NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Zhou Posted via mailing list.
|
Posted: Fri Nov 12, 2010 8:00 am Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
Hello,you must redirect your output to output window, like this:
<code>
public static void redirectSystemStreams(final String name) {
OutputStream out = new OutputStream() {
PrintWriter out=IOProvider.getDefault().getIO(name, false).getOut();
//PrintWriter out=IOProvider.getDefault().getStdOut();
public void write(int i) throws IOException {
out.print(String.valueOf((char) i));
}
@Override
public void write(byte[] bytes) throws IOException {
out.print(new String(bytes));
}
@Override
public void write(byte[] bytes, int off, int len) throws IOException {
out.print(new String(bytes, off, len));
}
};
InputStream in=new InputStream() {
private Reader in=IOProvider.getDefault().getIO(name, false).getIn();
@Override
public int read() throws IOException {
int i= in.read();
return i;
}
};
System.setOut(new PrintStream(out, true));
System.setErr(new PrintStream(out, true));
System.setIn(in);
Handler handler=new ConsoleHandler();
LogManager manager=LogManager.getLogManager();
Enumeration enum_ = manager.getLoggerNames();
while (enum_.hasMoreElements()) {
String loggerName = (String)enum_.nextElement();
Logger logger = manager.getLogger(loggerName);
if (logger != null) {
logger.addHandler(handler);
}
}
}
</code>
best wishes!
Zhou
At 2010-11-12 |
|
| Back to top |
|
 |
Kris Scorup Posted via mailing list.
|
Posted: Fri Nov 12, 2010 3:37 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
| Invoke the "View IDE Logs" (LogAction) action from the View menu. This will attach your logs and print statements to the Output window. In my application, this is the only |
|
| Back to top |
|
 |
Jensen, Jeffrey L Posted via mailing list.
|
Posted: Sun Nov 14, 2010 4:18 am Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
Kris, thanks for the suggestion but I think I did not state my problem as clearly as I could have. I am not trying to show logs or print statements in my platform application. During the development process I frequently run my application from within the IDE via the “run main project” F6 or “debug main project” Ctrl-F5 options. The Output window of the IDE is what is lacking my logging info and print statements to both std out and std err. Previous platform development in Netbeans 6.7.1 showed all of this information in the output window of the IDE without any special configuration or extra programming steps.
Further comments or suggestions are much appreciated,
Jeff
From: Kris Scorup [mailto:address-removed]
Sent: Friday, November 12, 2010 7:30 AM
To: address-removed
Subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE
Invoke the "View IDE Logs" (LogAction) action from the View menu. This will attach your logs and print statements to the Output window. In my application, this is the only thing I use Output for, therefor I hide the regular Output window options from the Windows menu by modifying the layer file.
To invoke that action on startup (if the Output window is open), see here http://wiki.netbeans.org/DevFaqLogActionStartup
On Thu, Nov 11, 2010 at 10:45 AM, Jensen, Jeffrey L <address-removed ([email]address-removed[/email])> wrote:
I have recently updated to Netbeans 6.9.1 on a 32bit windows XP machine and my logging and println statements no longer show up in the Output window of the IDE. Previously, with version 6.7.1, when launching my platform application from within the IDE (run or debug) all my println statements and logging showed up in the Output window.
A regular java application will produce this output however a platform application will not in 6.9.1. Any thoughts?
Thanks,
Jeff
--
Kris Scorup
Datahead Software Solutions
27733 215th PL SE
Maple Valley, WA 98038
425-310-2527 phone
http://www.dataheadsolutions.com
address-removed ([email]address-removed[/email]) |
|
| Back to top |
|
 |
Kris Scorup Posted via mailing list.
|
Posted: Sun Nov 14, 2010 6:26 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
| Ok, sorry for misunderstanding. |
|
| Back to top |
|
 |
Jensen, Jeffrey L Posted via mailing list.
|
Posted: Mon Nov 15, 2010 6:38 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
I have tried many of the things you suggest to no avail. I have created a very simple platform app with 6.9.1 that does nothing but print to std out when clicking a button and even that does not work. I have set the –J-Dnetbeans.logger.console =true and have no success there either. The log file generated by the platform in the ..\build\testuserdir\var\log\messages.log does not have any of my output in it either, it matches only what is displayed in the output window.
I noticed a few other users have posted similar problems. I have the same problem on both of my work computers, one with XP and the other with 64 bit Windows 7. Oddly, though, I do not have this problem on my personally owned netbook with Windows 7 starter. Also, logging and print lines work with non platform java applications on all my machines. Could this be a corporate firewall issue? Is logging and print line functionality in a platform application using local ports to pass its information to the output window of the IDE and to the log files?
Jeff
From: Kris Scorup [mailto:address-removed]
Sent: Sunday, November 14, 2010 10:19 AM
To: address-removed
Subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE
Ok, sorry for misunderstanding. I don't have any real suggestions for how to address that, just some thoughts on things I know that I'd try.
What version does your platform application use? If its using the older platform (6.7) perhaps upgrading to the newer platform will resolve this?
Did you clean & build the application from the new IDE?
If you create a new platform application in 6.9.1, do the print and logging statements show in the IDE? If so, as a last resort, you may be able to create a new platform application, then add your (existing) modules to it. Sounds like a lot of work to just get logging in the IDE working.
On Sat, Nov 13, 2010 at 8:11 PM, Jensen, Jeffrey L <address-removed ([email]address-removed[/email])> wrote:
Kris, thanks for the suggestion but I think I did not state my problem as clearly as I could have. I am not trying to show logs or print statements in my platform application. During the development process I frequently run my application from within the IDE via the “run main project” F6 or “debug main project” Ctrl-F5 options. The Output window of the IDE is what is lacking my logging info and print statements to both std out and std err. Previous platform development in Netbeans 6.7.1 showed all of this information in the output window of the IDE without any special configuration or extra programming steps.
Further comments or suggestions are much appreciated,
Jeff
From: Kris Scorup [mailto:address-removed ([email]address-removed[/email])]
Sent: Friday, November 12, 2010 7:30 AM
To: address-removed ([email]address-removed[/email])
Subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE
Invoke the "View IDE Logs" (LogAction) action from the View menu. This will attach your logs and print statements to the Output window. In my application, this is the only thing I use Output for, therefor I hide the regular Output window options from the Windows menu by modifying the layer file.
To invoke that action on startup (if the Output window is open), see here http://wiki.netbeans.org/DevFaqLogActionStartup
On Thu, Nov 11, 2010 at 10:45 AM, Jensen, Jeffrey L <address-removed ([email]address-removed[/email])> wrote:
I have recently updated to Netbeans 6.9.1 on a 32bit windows XP machine and my logging and println statements no longer show up in the Output window of the IDE. Previously, with version 6.7.1, when launching my platform application from within the IDE (run or debug) all my println statements and logging showed up in the Output window.
A regular java application will produce this output however a platform application will not in 6.9.1. Any thoughts?
Thanks,
Jeff
--
Kris Scorup
Error! Filename not specified.
Datahead Software Solutions
27733 215th PL SE
Maple Valley, WA 98038
425-310-2527 phone
http://www.dataheadsolutions.com
address-removed ([email]address-removed[/email])
--
Kris Scorup
Datahead Software Solutions
27733 215th PL SE
Maple Valley, WA 98038
425-310-2527 phone
http://www.dataheadsolutions.com
address-removed ([email]address-removed[/email]) |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Thu Nov 18, 2010 9:27 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
On 11/15/2010 01:30 PM, Jensen, Jeffrey L wrote:
| Quote: | Is logging and print line
functionality in a platform application using local ports to pass its
information to the output window of the IDE and to the log files?
|
No. Assuming -Dnetbeans.logger.console=true has been passed during startup, output should be displayed. On Windows, --console suppress may be needed for display inside
the Output Window. |
|
| Back to top |
|
 |
adamgmetzler
Joined: 27 Mar 2010 Posts: 22
|
Posted: Fri Nov 26, 2010 6:47 am Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
On 11/18/2010 3:00 PM, Jesse Glick wrote:
| Quote: | On 11/15/2010 01:30 PM, Jensen, Jeffrey L wrote:
| Quote: | Is logging and print line
functionality in a platform application using local ports to pass its
information to the output window of the IDE and to the log files?
|
No. Assuming -Dnetbeans.logger.console=true has been passed during
startup, output should be displayed. On Windows, --console suppress
may be needed for display inside the Output Window.
| What do you mean by "--console suppress may be needed?" Is this a
command line flag that can be passed to the run.args property, if so is
it just "--console" or is it "--console suppress"? I have been fighting
this since upgrading to 6.9 and 6.9.1 with a 64 bit JDK after switching
to a windows 7 development machine from a linux machine. |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Mon Nov 29, 2010 5:57 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
On 11/26/2010 01:38 AM, Adam G. Metzler wrote:
| Quote: | What do you mean by "--console suppress may be needed?"
|
Just a hint. I am not a regular Windows users and I don't know much about the rewritten 6.7+ NB launcher when this option was introduced.
| Quote: | Is this a command line flag that can be passed to the run.args property
|
Yes.
| Quote: | is it just "--console" or is it "--console suppress"?
|
Well ["--console", "suppress"] (option w/ arg), though run.args.extra already accepts multiple args separated by spaces. |
|
| Back to top |
|
 |
adamgmetzler
Joined: 27 Mar 2010 Posts: 22
|
Posted: Tue Nov 30, 2010 7:18 am Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
On 11/29/2010 11:38 AM, Jesse Glick wrote:
| Quote: | On 11/26/2010 01:38 AM, Adam G. Metzler wrote:
| Quote: | What do you mean by "--console suppress may be needed?"
|
Just a hint. I am not a regular Windows users and I don't know much
about the rewritten 6.7+ NB launcher when this option was introduced.
| Quote: | Is this a command line flag that can be passed to the run.args property
|
Yes.
| Quote: | is it just "--console" or is it "--console suppress"?
|
Well ["--console", "suppress"] (option w/ arg), though run.args.extra
already accepts multiple args separated by spaces.
| It seems that this does not work when building and running a RCP app
with a 64 bit JDK as when I switch the target to the 32 bit JDK all
works fine. Not sure why but no combination of `--console suppress` or
`"--console suppress"` or `"--console", "suppress"` worked with either
the `run.args` or `run.args.extra` property. All I get in the console is
the line `Post-initialization command-line options could not be run.`
while trying to use these options. So, could this be a JDK bug with
System.out and System.in redirection with the 64 bit build or a problem
with the fact that the netbeans launcher (.exe) for windows is 32 bit
regardless of the JDK it is run with? |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Wed Dec 01, 2010 7:39 pm Post subject: [platform-dev] Re: Logging and println to System.out and System.err not showing in Output window of IDE |
|
|
On 11/30/2010 02:09 AM, Adam G. Metzler wrote:
| Quote: | could this be a JDK bug with
System.out and System.in redirection with the 64 bit build or a problem
with the fact that the netbeans launcher (.exe) for windows is 32 bit
regardless of the JDK it is run with?
|
Possibly either. Best to file a bug in platform/Launchers & CLI so that someone w/ access to 64-bit Windows can debug this. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|