https://dagster.io/ logo
#ask-community
Title
# ask-community
d

Duncan

08/18/2022, 1:00 PM
Hi. I’m testing a dagster-decorated function (
@graph
) in an exception case, and as such I’d like to disable dagster’s logging as it makes a mess of the test’s logging output. However, calling
getLogger('dagster').setLevel(…
before the test does not seem to work - checking the logger after the test shows that it’s been force-reset in the interim. How can one actually disable the logging for the duration of a text execution?
🤖 1
s

sandy

08/18/2022, 3:43 PM
thoughts on this @owen?
o

owen

08/18/2022, 4:39 PM
hi @Duncan! This worked for me (you can set the level of
dagster.builtin
, just not
dagster
):
Copy code
import logging
from dagster import op, get_dagster_logger, build_op_context


@op
def foo(context):
    get_dagster_logger().debug("hi")
    return 1


def test_foo():
    dagster_logger = logging.getLogger("dagster.builtin")
    dagster_logger.setLevel("ERROR")
    foo(build_op_context())
    assert False
d

Duncan

08/19/2022, 10:12 AM
@owen Thanks ❤️ I will give that a whirl