Roshan r February 2016

Appending the log file using logging

I have written a code to do something. I have started a log also but when ever i start the program, the log files are not appending instead starting fresh. How can i append the log every time i start the script.

My code is as follows[Only the relevant section]:

import paramiko
import logging
from logging.config import fileConfig

paramiko.util.log_to_file("VersionScanner" + '.log')
logging.basicConfig(filename='VersionScanner.log', level=logging.DEBUG)

I am using both paramiko [ssh level logs ] and logging for application logging. Is there any way like using 'a' for appending here?

Answers


alpha1554 February 2016

It seems paramiko is at fault here. The specific line is this one :f = open(filename, 'w').

In order to go around this, you should declare a logger with the name paramiko and give it the desired configuration.

Post Status

Asked in February 2016
Viewed 2,826 times
Voted 4
Answered 1 times

Search




Leave an answer