Hi there
I am using logging
package in my server code and I have statements like:
import logging
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
logging.info('My Info Log')
I see these logs don’t appear in App’s Logs.
Is there a way to have these logs in my App’s Logs? Or I need to revert to the good plain old print()
?
Logging package is useful and has most of the things you need already built in.
1 Like
As a practical question, what would you add that is not already in Anvil’s logs?
Hi
well at least
- leveraging a built-in package designed to this purpose, with levels management, format management and every facility you could think of
- avoid refactoring existing codebases to “downgrade” logging management from using the builtin package to cusotm print() statements
- keep a single codebase that can run consistently between Anvil’s server environment and Uplinked servers, where built-in logging package is a best practice
I admit this is not indispensable but would be nice.
So, everyone is logging with print statements here?
2 Likes
I haven’t tried this, but what happens if you define a handler that directs to stdout and add that to your logger? Something like:
handler = logging.StreamHandler(sys.stdout)
logger.addHandler(handler)
All great points. Thanks for making me think! 
2 Likes
Next up: add a handler that also logs to a data table…
I feel an update to my orm coming shortly.
2 Likes
Ouch that was a big miss!
Thanks Owen!
I didn’t event think of that, you’re absolutely right and now that I read it I wonder how didn’t that come up to my mind myself…
This is why this forum is so helpful, I was missing a point as big as a mountain because I was looking at my feet…
1 Like
Not sure who Paul might be, but you’re welcome. Glad it helped!
1 Like
Ahahaha my aplogies
, my messed mind mixed your content with “p.colbert” !!
Thanks Owen and again sorry for that. I fix the attribution immediately. 
1 Like
Would you mind marking this one as solved?