uranusjr commented on code in PR #68938:
URL: https://github.com/apache/airflow/pull/68938#discussion_r3472453544
##########
airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst:
##########
@@ -341,15 +341,33 @@ Add the artifact:
implementation("org.apache.airflow:airflow-sdk-jul:${version}")
and call ``AirflowJulHandler.install()`` on startup to attach the handler to
the
-JUL root logger before any task runs:
+JUL root logger before any task runs. Remove JUL's default handlers first, so
+records flow only through ``AirflowJulHandler``:
.. code-block:: java
+ import java.util.logging.Handler;
+ import java.util.logging.Logger;
+
public static void main(String[] args) {
+ Logger root = Logger.getLogger("");
+ for (Handler h : root.getHandlers()) {
+ root.removeHandler(h);
+ }
AirflowJulHandler.install();
Server.create(args).serve(new MyBundle());
}
+.. note::
+
+ ``install()`` only adds the handler; it does not remove JUL's default
+ ``ConsoleHandler``. If you leave that handler in place, every record is
also
+ written to stderr, which Airflow captures separately as ``task.stderr`` at
+ ERROR level, so each line appears twice in the UI and ``INFO`` records are
+ mislabeled as errors. The ``logging.properties`` approach below avoids
this,
+ since the ``handlers`` property replaces the root handler set instead of
+ adding to it.
Review Comment:
I wonder if we should just do this automatically in `install()` (and maybe
even rename it to say ``setup()``)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]