Hi guys,
I am trying to use the Python logging API to log only to a file. The code below logs to only a file if I have it at the beginning of my class, right beneath the "class ..." line. If, however, I put it inside a method, it logs to both a file AND the console. :( What am I doing wrong? At one point I thought that perhaps another class file, being launched later in a separate thread, which also calls logging, somehow was messing up the handler or logging (I have now understood that if you do logging.basicConfig(...) in another class file in the same Python interpreter instance, it'll suddenly mess up logging.basicConfig(...) stuff you'll have done in another file). But, having globally searched my entire application files, I am sure I am not modifying logging later. Thanks a lot for any help.
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler = logging.FileHandler('/DifRec.txt')
handler.setFormatter(formatter)
fileLogger = logging.getLogger('DIFRECFILE')
fileLogger.addHandler(handler)
fileLogger.setLevel(logging.INFO)
fileLogger.info("Sending message...")