System.out.println on Mountain Lion

Michael Hall mik3hall at gmail.com
Sun Jan 13 03:36:47 PST 2013


On Jan 13, 2013, at 2:58 AM, Paul Taylor wrote:

> On 13/01/2013 01:26, Michael Hall wrote:
>> On Jan 12, 2013, at 7:19 PM, Mike Swingler wrote:
>> 
>>> As I recall (though I can't find any public documentation about this), the logging policy was changed in Mountain Lion to ignore ordinary inherited stdout/stderr, and to only log records into the ASL database that came through the ASL API (of which NSLog does use).
>> Might not always work for everyone but why not redirect standard i/o to custom classes that wrap NSLog's?
>> 
>> Michael Hall
> How do we do that, and 

Redirect i/o using the System.setOut method. Some permissions are involved, might not be available to all code.
Write a custom PrintStream subclass that passes it''s print,println and write methods off to JNI.
Write the JNI counterpart that takes the System.out print, println, and write parameters and instead passes them to NSLog.

My HalfPipe java shell application below does something similar for redirecting normal System.out to a Java text component, if indicated on the command line it also can redirect to a text file. I would suggest my own app but the console has become a bit complicated with interdependencies to the rest of the application over the years.

> why did Apple change this anyway ?

No idea. I'm still just Lion with no immediate plans to upgrade. I tend to ignore Mountain Lion specific discussion and remember no prior mention of this.

Michael Hall

trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz

HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe

AppConverter convert Apple jvm to openjdk apps http://www195.pair.com/mik3hall/index.html#appconverter




More information about the macosx-port-dev mailing list