Redirecting console.log to own Java logger

148 views
Skip to first unread message

Radu Coravu

unread,
Apr 5, 2022, 12:11:51 AM4/5/22
to mozilla-rhino
Hi,

If the Javascript code uses console.log, how can I re-direct it to my own Java logging code?

Regards,
Radu

P

unread,
Apr 8, 2022, 8:00:14 AM4/8/22
to mozilla-rhino
An addition just landed in Rhino for this: https://github.com/mozilla/rhino/pull/1103

With this, an embedder of Rhino can choose to include the `console` object in the JavaScript environment with their own ConsolePrinter implementation to redirect the content to where they like, see https://github.com/mozilla/rhino/wiki/DRAFT:-Rhino-1.7.15-Release-Notes#non-ecmascript-features for some pointers

This new feature will be part of Rhino 1.7.15 (for which there's no planned release date). But you can copy the Console impl. to your own project for the time being if you want 

Radu Coravu

unread,
Jul 4, 2022, 11:41:34 PM7/4/22
to mozilla-rhino
Hi,
Thanks for the help, sorry I did not see your reply sooner.
Regards,
Radu
Reply all
Reply to author
Forward
0 new messages