Remove stdout log capture

Bug #802396 reported by Lars Butler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenQuake (deprecated)
Fix Released
Medium
Mattia Barbon

Bug Description

Recently, we revised our logging methods to capture (in a unified fashion) logging info from Python stdout, Python logging, Java stdout, and Java logging. The unified logging is good, but I think we should not be capturing stdout. Here's why:

If you run the OQ engine with cProfile, all of the nice cProfile formatted output is destroyed and gets turned into logging messages.

To reproduce, run this:

$ python -m cProfile bin/openquake --config_file=whatever/config.gem

Revision history for this message
Gabriele Favalessa (favalex) wrote :

I agree, capturing stdout make lots of stuff messy (another example is using
the pdb debugger).

The current situation was intended as an intermediate step anyway, with the aim
of using rabbitmq for logging eventually.

I think we are very close: after landing
https://github.com/gem/openquake/pull/150 and
https://github.com/gem/openquake/pull/304 all the logging output will be going
through the logging modules of python and java (no more prints to stdout).

Sending the output to rabbitmq will be a matter of configuring the logging
modules to use the proper backend.

For log4j I found this http://github.com/jbrisbin/vcloud/tree/master/amqp-appender/

and for python this http://notes.variogr.am/post/143623387/broadcasting-your-logs-with-rabbitmq-and-python .

BTW pull request https://github.com/gem/openquake/pull/150 is actually just
removing some obsoleted files. These files have been modified in the meantime,
making the automatic merge impossible. The gist of the pull request would be
on the other hand really easy to replicate, with a simple rm. Thus I suggest
landing 304 and then open another pull request to remove the files, without
bothering with 150 anymore.

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Apparently this is still an issue. When I run this command

    nosetests -s tests/*_unittest.py > test.log 2>&1

I don't see any output in the terminal but the test.log file is not there either.

Changed in openquake:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Gabriele Favalessa (favalex) wrote :

I put here some comments on the background behind the current situation.

Whatever we end up implementing we have to keep this in mind.

 - If java logging goes directly to its destination without being captured by
   python the lines in the log don't have information about the worker. Hence
   the trick to send java logging to a proxy stdout, capture it in python and
   then spit it out again with the worker id attached

   The code doing the capturing of the java stdout is in openquake/java.py
   _setup_java_capture() called when starting the jvm

 - In the context of nosetests by default a logging capture mechanism is in
   place (see http://somethingaboutorange.com/mrl/projects/nose/0.11.1/plugins/logcapture.html
   ) and that for sure interfers with our own capture.

  It can be disabled with --nologcapture .

John Tarter (toh2)
Changed in openquake:
milestone: none → 0.4.3
Revision history for this message
Mattia Barbon (mattia.barbon) wrote :

To add information about the worker to the Java logs, we could put multiprocessing.current_process().name in the Java MDC; the only drawback is that it's not documented that that is the process name used by Celery logs.

Changed in openquake:
status: Confirmed → In Progress
assignee: nobody → Mattia Barbon (mattia.barbon)
Revision history for this message
Mattia Barbon (mattia.barbon) wrote :

Most of the functionality is already in master (as of https://github.com/gem/openquake/commit/b0e86fe3d62a9 ); the only missing bit is adding the process name to log messages.

Revision history for this message
Mattia Barbon (mattia.barbon) wrote :
Changed in openquake:
status: In Progress → Fix Committed
Changed in openquake:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.