Open ManelBH opened 1 year ago
Thanks for reporting we will discuss this feature issue and update you on the inputs soon.
@bhagyshricompany Any update on this?
@Qmatteo its in progress
@bhagyshricompany any idea on the timeline?
will update
@bhagyshricompany "will update" ???
@bhagyshricompany Any update yet?
I'm facing the same issue, I see another linked issue has a merged PR but I'm still observing the problem with fastapi
Another "I'm facing the same issue" post, would it be possible for someone to give an update please so we don't have to guess?
As Giuseppe said above I can see that https://github.com/Azure/azure-functions-python-worker/pull/1171 has been merged 2 weeks ago but there has not been a core tools release yet. This issue is still open: https://github.com/Azure/azure-functions-python-worker/issues/1158 so it's hard to know what the status of this is.
It would be much appreciated! Without the logging on these synchronous defined functions suddenly the overall Azure Function I was building becomes impossible to monitor.
@bhagyshricompany any update on this? The fix described in this thread https://github.com/Azure/azure-functions-python-worker/issues/1158 doesn't seem to work for me
@bhagyshricompany ANY UPDATES ON THIS, PLEASE?
Hi, I just wanted to add a solution to this. We can fetch the current logger with getLogger() and use it accordingly. Here is a sample:
# logger.py
import logging
loggers = {}
def myLogger(name):
global loggers
if loggers.get(name):
return loggers.get(name)
else:
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
logger.addHandler(handler)
loggers[name] = logger
return logger
# app.py
from logger import myLogger
# and your other imports
@api_router.get(
"/hello/{name}",
description="Get name"
)
def get_name(name: str):
logger = myLogger(__name__)
logger.info(f"/hello/ endpoint. Name: {name}.")
return {
"name": name,
}
The log in get_name() shows up upon execution as intended. Note that there may be issues with tracking as handle() (non-async) is deprecated
I have posted a workaround in the https://github.com/Azure/azure-functions-python-worker/issues/1158 thread's comment
To anyone else here, @nikie 's solution worked for me, although not out-of-the-box (makes some assumptions about the server you're using)
Also found that certain types of logging didn't work for me on Azure. More here - @nikie your solution worked for me, although not out of the box, since I was using some custom middleware written a couple years ago.
I also experienced some other quirks with Azure logging. I expanded upon it here - https://stackoverflow.com/a/78738009/5469472
This issue is for a: (mark with an
x
)Minimal steps to reproduce
Expected/desired behavior
Expected: A line with the logged text appears in the logs (same behaviour as with async operations) Actual: Nothing is logged.
OS and Version?
Windows 10
Versions
Python version: 3.9.10 Core Tools Version: 4.0.4704 Function Runtime Version: 4.7.3.18953 azure-functions==1.12.0 fastapi==0.88.0