Redirecting log information
Tom Schindl
tom.schindl at bestsolution.at
Thu May 10 08:50:56 PDT 2012
Ok I think I'm getting closer. If I do this:
> PlatformLogger.redirectPlatformLoggers();
> PlatformLogger cssLogger = Logging.getCSSLogger();
> cssLogger.severe("Hello Log");
I get on JDK-6:
SEVERE: test.TestApp start Hello Log
On JDK-7:
=> An exception on start up
> Exception in Application start method
> Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
> at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:399)
> at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
> at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
> at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.ExceptionInInitializerError
> at com.sun.javafx.logging.PlatformLogger.redirectPlatformLoggers(PlatformLogger.java:144)
> at test.TestApp.start(TestApp.java:19)
> at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:315)
> at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:174)
> at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:141)
> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
> at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
> at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
> ... 1 more
> Caused by: java.lang.ClassCastException: java.util.logging.LoggingProxyImpl cannot be cast to com.sun.javafx.logging.LoggingProxy
> at com.sun.javafx.logging.LoggingSupport$1.run(LoggingSupport.java:56)
> at com.sun.javafx.logging.LoggingSupport$1.run(LoggingSupport.java:48)
> at java.security.AccessController.doPrivileged(Native Method)
> at com.sun.javafx.logging.LoggingSupport.<clinit>(LoggingSupport.java:47)
> ... 9 more
So it looks like
on JDK-6:
* Does not care about the redirectPlatformLoggers and simply writes to
STDERR
on JDK-7:
* It's not working at all.
Am 10.05.12 16:55, schrieb Tom Schindl:
> Hi,
>
> To me it looks like e.g. the CSS-Engine (and all other stuff) is not
> logging through java.util.Logger but through:
>
> PlatformLogger cssLogger = Logging.getCSSLogger();
>
> which at least in my current test ends up in
>
>> Thread [JavaFX Application Thread] (Suspended)
>> PrintStream.println(String) line: 755
>> PlatformLogger$LoggerProxy.doLog(int, String) line: 361
>> PlatformLogger.severe(String) line: 217
>> TestApp.start(Stage) line: 22
>> LauncherImpl$5.run() line: 315
>> PlatformImpl$4.run() line: 174
>> PlatformImpl$3.run() line: 141
>> WinApplication._runLoop(String[], Launchable) line: not available [native method]
>> WinApplication.access$100(WinApplication, String[], Launchable) line: 29
>> WinApplication$2$1.run() line: 62
>> Thread.run() line: 662
>
> I wished the source of this would be available ;-)
>
> Tom
>
> Am 08.05.12 18:54, schrieb Richard Bair:
>> Ya, both JDK logging and JFX logging have the same flag checks available.
>>
>> On May 8, 2012, at 9:06 AM, Phil Race <philip.race at oracle.com> wrote:
>>
>>> I think the graphics code mostly if not always, guards those printlns with a check for
>>> a debugging flag. Unless used in a similar manner, the logging API carries overhead.
>>> There was a fix in JDK 7 to eliminate dependency on logging from AWT/2D/Swing.
>>> In part that was because of modularisation .. I don't know the full story on why
>>> that mattered.
>>>
>>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6879044 :
>>> Eliminate the dependency on logging from the AWT/2D/Swing classes
>>>
>>> -phil.
>>>
>>> On 5/8/2012 8:28 AM, Kevin Rushforth wrote:
>>>> This would certainly make everyone's life easier.
>>>>
>>>> In any case, library code should never write debug/warning/error meesages to System.out / stdout (and yes, I know that some of the graphics currently does). Best is to use logging where possible for the reasons Richard mentioned, and System.err / stderr where not.
>>>>
>>>> -- Kevin
>>>>
>>>>
>>>> Richard Bair wrote:
>>>>> Not all JavaFx code is consistent on logging. In particular, the graphics code just uses System.out and System.err, whereas controls use a Logger which goes to System.out unless you enable JDK logging, in which case it uses a JDK Logger.
>>>>>
>>>>> I feel we ought to use the same logging method consistently, and then it should be quite easy for you to redirect by utilizing the JDK logging mechanism?
>>>>>
>>>>> On May 8, 2012, at 5:19 AM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> The problem is the point at which one redirects the stderr. Take a look
>>>>>> at this:
>>>>>>
>>>>>>> public class TestApp extends Application {
>>>>>>>
>>>>>>> @Override
>>>>>>> public void start(Stage primaryStage) {
>>>>>>> ByteArrayOutputStream out = new ByteArrayOutputStream();
>>>>>>> PrintStream orig = System.err;
>>>>>>> System.setErr(new PrintStream(out)); // Works
>>>>>> vs.
>>>>>>
>>>>>>> public class TestApp extends Application {
>>>>>>>
>>>>>>> @Override
>>>>>>> public void start(Stage primaryStage) {
>>>>>>> ByteArrayOutputStream out = new ByteArrayOutputStream();
>>>>>>> PrintStream orig = System.err;
>>>>>>> Group g = new Group();
>>>>>>> System.setErr(new PrintStream(out)); // Does not work
>>>>>> The problem is that Option 1 is not possible for me because I only have
>>>>>> to redirect the logging information from JavaFX while your solution
>>>>>> completely redirects STDERR with is not making much sense!
>>>>>>
>>>>>> Sad enough the Logging code is not yet opensourced so I still hope that
>>>>>> a JavaFX dev with access to the code can help me.
>>>>>>
>>>>>> So I repeat my question. Can I somehow set a custom logger to the JavaFX
>>>>>> platform?
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>> Am 08.05.12 00:22, schrieb Tom Schindl:
>>>>>>> I've tried that already and couldn't make it work. Did you try it and it
>>>>>>> worked? Then I'd give another try.
>>>>>>>
>>>>>>> Tom
>>>>>>>
>>>>>>> Am 08.05.12 00:25, schrieb Christian Schudt:
>>>>>>>> You can redirect the System.err stream to your logger.
>>>>>>>>
>>>>>>>> See here:
>>>>>>>>
>>>>>>>> https://forums.oracle.com/forums/thread.jspa?messageID=10304321
>>>>>>>> http://stackoverflow.com/questions/1200175/log4j-redirect-stdout-to-dailyrollingfileappender/1370033#1370033
>>>>>>>>
>>>>>>>> Christian
>>>>>>>>
>>>>>>>>
>>>>>>>> Am 07.05.2012 um 23:06 schrieb Tom Schindl:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I'm having a hard time redirecting log output generated by JavaFX
>>>>>>>>> library. Is there some API available or documentation?
>>>>>>>>>
>>>>>>>>> Tom
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> B e s t S o l u t i o n . a t EDV Systemhaus GmbH
>>>>>>>>> ------------------------------------------------------------------------
>>>>>>>>> tom schindl geschäftsführer/CEO
>>>>>>>>> ------------------------------------------------------------------------
>>>>>>>>> eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
>>>>>>>>> http://www.BestSolution.at phone ++43 512 935834
>>>>>> --
>>>>>> B e s t S o l u t i o n . a t EDV Systemhaus GmbH
>>>>>> ------------------------------------------------------------------------
>>>>>> tom schindl geschäftsführer/CEO
>>>>>> ------------------------------------------------------------------------
>>>>>> eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
>>>>>> http://www.BestSolution.at phone ++43 512 935834
>>>
>
>
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
http://www.BestSolution.at phone ++43 512 935834
More information about the openjfx-dev
mailing list