Message13076

Author jeff.allen
Recipients doublep, jeff.allen
Date 2020-05-31.07:04:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590908658.82.0.563097297701.issue2896@roundup.psfhosted.org>
In-reply-to
Content
The good reason is that logging in the console command is a replacement for the way we previously produced messages, which was also entirely disconnected from other systems of logging. In the console command, where this code applies, the idea was for log messages to appear much as they had before, by means of a custom format (which you won't like either since it affects all simple logging).

If logging bubbles up to root as well, then with default settings, the ISTR user gets each message twice.

In jython the command-line command, we feel free to do all that because it *is" the application. When Jython is used embedded, it seemed sensible let the messages enter the normal logging hierarchy, and not muck about with the format.

User experience/expectations are important, however. I guess you are using the command line utility to launch your application, but it runs "unobserved", hence the need for logging. JUL is very configurable: you can adjust things to your liking.

PS jython-nightjar> dist\bin\jython
Jython 2.7.3a1-DEV (uncontrolled:+, May 30 2020, 20:41:06)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_241
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.util.logging import Logger, Level
>>> rootlogger = Logger.getLogger("")
>>> pylogger = Logger.getLogger("org.python")
>>>
>>> rootlogger.warning("Hello")
 WARNING Hello
>>> pylogger.warning("Hello")
org.python WARNING Hello
>>>
>>> pylogger.useParentHandlers
False
>>> pylogger.useParentHandlers = True
>>> pylogger.warning("Hello")
org.python WARNING Hello
org.python WARNING Hello
>>>

This last illustrates what motivated the disconnection: two messages when you only need one, and both in the abbreviated format suited to a console application. But it may have been better to do just one of these things (tweak the format universally and just let messages bubble up, *or* prevent bubbling up and tweak the format just for org.python).

If you choose your own format, Jython won't impose its own:

PS jython-nightjar> dist\bin\jython -D'java.util.logging.SimpleFormatter.format=%1$tl:%1$tM:%1$tS %1$Tp %4$s: %5$s%6$s%n'
Jython 2.7.3a1-DEV (uncontrolled:+, May 30 2020, 20:41:06)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_241
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.util.logging import Logger
>>> rootlogger = Logger.getLogger("")
>>> pylogger = Logger.getLogger("org.python")
>>> rootlogger.warning("Hello")
8:01:52 AM WARNING: Hello
>>> pylogger.warning("World")
8:02:03 AM WARNING: World
History
Date User Action Args
2020-05-31 07:04:18jeff.allensetmessageid: <1590908658.82.0.563097297701.issue2896@roundup.psfhosted.org>
2020-05-31 07:04:18jeff.allensetrecipients: + jeff.allen, doublep
2020-05-31 07:04:18jeff.allenlinkissue2896 messages
2020-05-31 07:04:18jeff.allencreate