#πŸ”’ Looking for simple text file logging library

17 messages Β· Page 1 of 1 (latest)

terse heath
#

Is there a loging library that has log to text file, and keep text file size to eg 1 GB? Looking for reccomendations

tulip cargoBOT
#

@terse heath

Python help channel opened

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.

cyan wyvern
#

yes there is builtin library which is logger

#

if you want to limit your log file size you can use the Rotation method

graceful cradle
#

There's a lot of good logging solutions there

#

!d logging

tulip cargoBOT
#

Source code: Lib/logging/__init__.py...

graceful cradle
#

!d logger

tulip cargoBOT
#

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.

graceful cradle
#

Python has built-in logging

terse heath
#

thank to both that first one i thought was library, but actually object

graceful cradle
#

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.

tulip cargoBOT
#
Python help channel closed

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.