System.console() (when using cygwin) is null and therefore you can't use console logging

123 views
Skip to first unread message

Dwayne Smurdon

unread,
Jun 3, 2014, 12:24:26 AM6/3/14
to quick...@googlegroups.com
When starting your server, you may see:

Loading QuickServer v2.0.0 [PID:5704]... Done
QuickServer: You do not have a console.. so turning console logger off..
Jun 02, 2014 11:09:09 PM org.quickserver.net.server.QuickServer setConsoleLoggingLevel
INFO: QuickServer: Removing console handler..

I tracked down the issue, and for me it was that I was running under cygwin.  This is not a QS issue at all.  Also, if you're reading this and you're not under cygwin but are getting the problem, I also read that if you start the server from Eclipse (or perhaps other IDE's), you System.console() may also return null.


Here's a related issue about the problem in general:  https://code.google.com/p/mintty/issues/detail?id=244.  That issue also references: http://download.oracle.com/javase/6/docs/api/java/io/Console.html) which has a more detailed conversation about it.

I haven't figured out a workaround yet. I'd like to use some of the convenience methods like ClientHandler.sendSystemMsg(). Even, if in the end, it just logs to a file, I could live with that.

I know there must be some type of workaround, because if I use log4j logging, it is able to the console. I think it ends up using System.out to do so...


Here is the code I believe is relevant to this: Quickserver.java (about line 1200 in 2.0.0)....

for(int index = 0; index < handlers.length; index++ ) {
if(ConsoleHandler.class.isInstance(handlers[index])) {
if(isConsole==false && level!=Level.OFF) {
System.out.println("QuickServer: You do not have a console.. so turning console logger off..");
level=Level.OFF;
}
if(level==Level.OFF) {
logger.info("QuickServer: Removing console handler.. ");
rlogger.removeHandler(handlers[index]);
handlers[index].setLevel(level);
handlers[index].close();
} else {
handlers[index].setLevel(level);
}
}
}

Reply all
Reply to author
Forward
0 new messages