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

Charles

08/02/2022, 12:05 PM
I'm getting dasgter logger like this
py_logger = get_dagster_logger("py_logger")
and then logging error calls like this
py_logger.error(f"Exception {type(e)}: ", Exception(e))
inside an
@asset
however
ERROR
calls aren't being shown - why is this? Screenshot is relevant section of
dagster.yaml
🤖 1
o

owen

08/02/2022, 4:35 PM
hi @Charles -- do those log messages show up anywhere (such as in Dagit), or are they completely missing? and do you mind sharing what the code inside the @asset looks like? (I don't need to see the actual logic, just curious about the structure)
c

Charles

08/02/2022, 5:24 PM
Copy code
@asset
def get_data() -> pd.DataFrame: # "get live data"
    try:
        # do stuff
        <http://py_logger.info|py_logger.info>("Data downloaded!")
    except AssertionError as e:
        py_logger.error("AssertionError Data has less observation than min history!", Exception(e))
    except Exception as e:
        print("This is triggered, but error below is not shown")
        py_logger.error(f"Exception {type(e)}: ", Exception(e))
    finally:
        return data
I'm running in debug using PyCharm, here's the configuration. The error in question is not shown in the PyCharm console.
o

owen

08/02/2022, 5:41 PM
This might not be the entire story, but at least part of what's going on here seems to be that the line that's supposed to produce the log message is itself causing an exception:
py_logger.error(f"Exception {type(e)}: ", Exception(e))
should instead be something like
py_logger.error(f"Exception {type(e)}: {e})")
basically, the log statement doesn't work in the same way as the print statement, and the entire message needs to be passed in as the first argument