#π Looking for simple text file logging library
17 messages Β· Page 1 of 1 (latest)
@terse heath
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
yes there is builtin library which is logger
if you want to limit your log file size you can use the Rotation method
@terse heath check this out https://docs.python.org/3/howto/logging-cookbook.html
There's a lot of good logging solutions there
!d logging
Source code: Lib/logging/__init__.py...
!d logger
Logger Objects
Loggers have the following attributes and methods. Note that Loggers should NEVER be instantiated directly, but always through the module-level function logging.getLogger(name). Multiple calls to getLogger() with the same name will always return a reference to the same Logger object.
Python has built-in logging
thank to both that first one i thought was library, but actually object
I think you'll find the Cookbook quite useful. There is also a how-to here: https://docs.python.org/3/howto/logging.html
What RaghavKumar is talking about it also there - what you're looking to do is use a Rotation Handler to rotate the log at when a particular condition is met (in your case when it reaches a certain size).
It's very versatile.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.