Skip to content
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

java console log messages are printed after termination #744

Open
ismailsimsek opened this issue Jan 29, 2025 · 3 comments
Open

java console log messages are printed after termination #744

ismailsimsek opened this issue Jan 29, 2025 · 3 comments

Comments

@ismailsimsek
Copy link

ismailsimsek commented Jan 29, 2025

using pyjnius so far everything is working fine.

except the java log messages are not streamed to console. they are appearing after the program terminated.

since the python APP going to continuously run, is it possible to get the java log messages appear on the console immediately?

java libraries are using log4j2 for logging

@ismailsimsek ismailsimsek changed the title Is it possible to see java console log output dusing the excetution java console log messages are printed after termination Jan 29, 2025
@cmacdonald
Copy link
Contributor

Thats not my experience. What I have done though is capture System.out and System.err in java and redirect them to jupyter console (via sys.stdout/sys.stderr). This works even for slf4j logging done in Java.

https://github.com/terrier-org/pyterrier/blob/master/pyterrier/java/_core.py#L99-L153

@ismailsimsek
Copy link
Author

thank you @cmacdonald for the reference, i will check it.

it seems like some kind of intellij + unittest issue.. Running the code as python script prints the logs as normal/immediately.

@cmacdonald
Copy link
Contributor

cmacdonald commented Jan 30, 2025

Yes, some applications, like pytest or jupyter will capture/redirect the Python stdout and that can cause problems with the Java side not behaving like your expect. The code above (plus some associated Java code) redirects the java stdout/err to the Python equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants