You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to try out loguru instead of the standard logging. However, I have one issue where I kinda find no solution to it.
My main issue is that I have multiple loggers. I use one for my application and two more for libraries (like logging.getLogger("uvicorn.access")). My main application logs on INFO, while for the libraries I use WARNING.
So for example currently I have
My application logging to console with INFO and to file (application.logs) with INFO
the uvicorn logs are with WARNING to console and INFO to uvicorn.logs
Both have different formatter.
I tried with loguru something like
logger.add(sys.stderr, level=logging.INFO)
logger.add("logs/application.log", level=logging.INFO)
for_login ["uvicorn.access", "uvicorn", "uvicorn.error", "fastapi"]:
# Found here on some issue I guess._logger=logging.getLogger(_log)
_logger.handlers= [InterceptHandler(_log)]
logger.add(f"logs/{_log}.log", level=logging.INFO)
logger.add(sys.stderr, level=logging.WARNING)
but thats obviously not possible.
So basically I want to have different log levels on different loggers. I tried the filter but couldn't make it work. I either get no logs or all logs in all files.
In addition I would also like to be able to:
Put each application/library to it's own log file
Have different extra/format for each application/library
Is this in general possible with loguru?
The text was updated successfully, but these errors were encountered:
Thanks for your reply! Sorry, I am a bit busy atm. I will try out your posted filter and provide more information once I visit that topic again. Hopefully within the next few weeks.
Hi!
I wanted to try out loguru instead of the standard logging. However, I have one issue where I kinda find no solution to it.
My main issue is that I have multiple loggers. I use one for my application and two more for libraries (like
logging.getLogger("uvicorn.access")
). My main application logs onINFO
, while for the libraries I useWARNING
.So for example currently I have
uvicorn
logs are withWARNING
to console andINFO
to uvicorn.logsI tried with loguru something like
but thats obviously not possible.
So basically I want to have different log levels on different loggers. I tried the
filter
but couldn't make it work. I either get no logs or all logs in all files.In addition I would also like to be able to:
extra
/format
for each application/libraryIs this in general possible with loguru?
The text was updated successfully, but these errors were encountered: