-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add %log start|off|on|state|level|stop for kernel logging #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
any feedback/comments? |
|
I was able to play with it locally, and this is pretty neat, and I am +1 on the feature in general. The overall logging architecture was something we needed to revisit, and I think this magic will work much more nicely once we do it: SLF4J vs JUL (Java built-in logging)My preference is generally SLF4J, but maybe this is just because JUL outputs 2 lines by default, and I am annoyed by it 🙂 (I know it can be customized with a formatter for a 1-line output). FWIW, SLF4J + Logback would allow lots of advanced configuration of output files, rotation and such. Various log originsLogs can come from the notebook, the libraries used in the notebook, and the kernel itself. All of them can be using different loggers:
The suggested magic would only do log routing for JUL loggers: // this would get rerouted to file
java.util.logging.Logger.getLogger("test").info("JUL log");
// this will be ignored
org.slf4j.LoggerFactory.getLogger(DataFrame.class).info("DFLib log");
// this will be output within the notebook
System.err.println("Error!")So, how do we decide which one goes where? Does the ipython |
|
I would refrain from using/forcing log4j by default - can always use and wire it up specifically if you really need it. log4j should just use log4j-jul and things should be aligned? |
|
about stdout/stderr - then those are "lost". stdout goes to notebook anyways - and stderr is not visible afaik (haven't tested/verified). I wouldn't include them in any log control. |
Ok, this turned out to be a non-issue once we fixed the underlying bugs and did proper dependency shading.
Stderr goes into notebook as well (with red background). FWIW, we control both those streams and can send them anywhere.
Fair enough. Let me flip the question then - most Java loggers by default (with no explicit config) send logs to stdout. So following that logic, the output of I hope this is not a big deal, and just some prior IJava decision inherited by JJava that we can easily deal with. Just outlining the scope of work 🙂 And this takes us to another Jupyter-specific thing: there two logical "consoles" - the notebook itself, and the Jupyter server console (logging in the latter is a hot mess now with a mix of python, 2-line JUL, and SLF4J warnings). So should the
|
|
Talking of SLF4J, somehow it managed to get into our main distro jar through a transitive dependency - #99 It is just everywhere these days. Anyways, after fixing that task, I experimented with it in a notebook, and it looks pretty good... Sending logs to notebook%maven org.slf4j:slf4j-simple:2.0.15
import org.slf4j.*;
Logger logger = LoggerFactory.getLogger("nl");
logger.info("Hi!")With
Sending logs to JUL%maven org.slf4j:slf4j-jdk14:2.0.15
import org.slf4j.*;
Logger logger = LoggerFactory.getLogger("nl");
logger.info("Hi!")With So:
|

its notoriously hard to get kernel output so added ipython inspired %log commands magic
to enable better inspection.
with this the kernel can start adding logging more widespread for easier debugging.