TimedRotatingFileHandler Changing File Name?

前端 未结 5 1593
臣服心动
臣服心动 2020-12-04 22:48

I am trying to implement the python logging handler TimedRotatingFileHandler.

When it rolls over to midnight it appends the current day in the form

5条回答
  •  既然无缘
    2020-12-04 23:04

    Just an update, i ended up going a different approach.

    The easiest way i found to modify the file output, was to simply use a FileHandler, then when it is time to do a roll over.

    I do this:

    if(current_time > old_time):
        for each in logging.getLogger('Debug').handlers:
          each.stream = open("C:\\NewOutput", 'a')
    

    Thats the gist of it. It took alot of poking and looking around but modifying the stream is the easiest way to do so.

    :)

提交回复
热议问题