Python Forum
Python logging RotatingFileHandler and TimedRotatingFileHandler is not working with Q
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python logging RotatingFileHandler and TimedRotatingFileHandler is not working with Q
#1
New logging packages (RotatingFileHandler & TimedRotatingFileHandler) is not working as per expectation.

problem: It creates the number of files as much defined by the user(backupCount) without completing its maxBytes limit.

It creates any size of the file even if the user defines maxBytes(file size could be in 10kb 34B etc.)

It sends log anywhere in any file its too random.


New logging packages (RotatingFileHandler & TimedRotatingFileHandler) is not working as per expectation.

problem: It creates the number of files as much defined by the user(backupCount) without completing its maxBytes limit.

It creates any size of the file even if the user defines maxBytes(file size could be in 10kb 34B etc.)

It sends log anywhere in any file its too random.

I request please fix this issue as soon as possible we are facing so many difficulties while using logging packages

file1: #For adding in queue

import redis 
from newTesting1 import executeJobQueue
import json
import time
from apscheduler.schedulers.background import BackgroundScheduler
conn = redis.Redis('127.0.0.1')
def addInQueue(queueName, PartnerId, CompanyName):
    newQ = Queue(queueName, connection=conn)
    for i in range(1000):
        newQ.enqueue(executeJobQueue, str(json.dumps({"ObjectId":"", 
                       "DisplayName":"", "FirstName":"", "LastName":"", 
                       "UserPrincipalName":"", "IsLicensed":"", 
                       "Licenses":"", "City":""})))

if __name__ == "__main__":
    scheduler = BackgroundScheduler()
    scheduler.start()
    scheduler.add_job(addInQueue, 'cron', ["syncDirectoryQueue", None, None], month='*', day='*', hour='10', minute='12')
    while True:
        time.sleep(3000)
File 2: Processing from the queue

from rq import Worker, Queue, Connection
import redis
conn = redis.Redis('127.0.0.1')
import logging.handlers
import logging
logger = logging.getLogger('MyLogger')
logger.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler("/Users/SMishra/log/application", maxBytes=100000, backupCount=10)
logger.addHandler(handler)

def executeJobQueue(newEntry):
    rq = Queue('syncDirectoryQueue', connection=conn)
    logger.info("executing queue %s %s", newEntry, len(rq))
    logger.info("executing queue %s %s", newEntry, len(rq))
    logger.info("executing queue %s %s", newEntry, len(rq))
    logger.info("executing queue %s %s", newEntry, len(rq))

if __name__ == "__main__":
    with Connection(conn):
        worker = Worker(list(map(Queue, ['syncDirectoryQueue'])))
        worker.work()
output:

-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.10
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.9
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.8
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.7
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.6
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.5
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.4
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.3
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.2
-rw-r--r-- 1 SMishra staff 632B Dec 23 10:13 application
-rw-r--r-- 1 SMishra staff 1.2K Dec 23 10:13 application.1
Reply
#2
cross-posted on SO
https://stackoverflow.com/questions/59447480/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I would suggest reading https://docs.python.org/3/howto/logging-...-processes

and also https://stackoverflow.com/questions/4796...processing
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 417 Feb-15-2024, 11:15 AM
Last Post: rawatg
  logging: change log file permission with RotatingFileHandler erg 0 1,050 Aug-09-2023, 01:24 PM
Last Post: erg
  Python logging error Mekala 2 1,949 Jun-25-2020, 04:03 AM
Last Post: Mekala
  Python Logging and Handling phillyfa 2 4,586 Mar-20-2020, 05:13 PM
Last Post: phillyfa
  import logging not working segerhult 3 13,237 Feb-07-2019, 05:31 PM
Last Post: buran
  Logging in python saisankalpj 1 2,428 Nov-12-2018, 05:00 PM
Last Post: ichabod801
  Error while Logging on to outlook email account using Python inside VDI Shilton 0 4,315 Sep-09-2018, 06:53 AM
Last Post: Shilton
  Logging module stopped working! llanitedave 1 8,000 Oct-18-2017, 06:45 AM
Last Post: llanitedave
  Asynchronous Logging in python 2.7 Elbi 4 8,514 Oct-09-2016, 06:10 PM
Last Post: Elbi

Forum Jump:

User Panel Messages

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