Python Forum
create new log file on logging?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create new log file on logging?
#5
You can add a handler of type RotatingFileHandler. Check the documentation and make sure you don't set either maxBytes or backupCount to 0. You could modify your earlier logging setup like so:

import logging
from logging.handlers import RotatingFileHandler
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s %(message)s'),
    handlers=[RotatingFileHandler('/home/pi/logs/App1_log.log', maxBytes=1000000, backupCount=4),
    )
buran likes this post
Reply


Messages In This Thread
create new log file on logging? - by korenron - Mar-21-2022, 02:37 PM
RE: create new log file on logging? - by deanhystad - Mar-21-2022, 02:52 PM
RE: create new log file on logging? - by korenron - Mar-21-2022, 03:15 PM
RE: create new log file on logging? - by deanhystad - Mar-21-2022, 03:40 PM
RE: create new log file on logging? - by bowlofred - Mar-21-2022, 03:49 PM
RE: create new log file on logging? - by snippsat - Mar-21-2022, 05:29 PM
RE: create new log file on logging? - by korenron - Mar-22-2022, 07:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can rich.logging output to file? pyfoo 1 510 Mar-21-2024, 10:30 AM
Last Post: pyfoo
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 559 Feb-15-2024, 11:15 AM
Last Post: rawatg
  Create Choices from .ods file columns cspower 3 842 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  Recommended way to read/create PDF file? Winfried 3 3,159 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  Use PM4PY and create working file thomaskissas33 0 855 Nov-14-2023, 06:53 AM
Last Post: thomaskissas33
  Create csv file with 4 columns for process mining thomaskissas33 3 946 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  logging: change log file permission with RotatingFileHandler erg 0 1,264 Aug-09-2023, 01:24 PM
Last Post: erg
  create exe file for linux? korenron 2 1,099 Mar-22-2023, 01:42 PM
Last Post: korenron
  my first file won't create itself MehHz2526 2 1,023 Nov-27-2022, 12:58 AM
Last Post: MehHz2526
  Create multiple/single csv file for each sql records mg24 6 1,627 Sep-29-2022, 08:06 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020