Lasse Bøg
Lasse Bøg

Reputation: 3

Python logging, not getting any output

I am sorry to ask, as it is not the first time, but I have not been able to fix it my self by looking at older posts.

Im trying to create and write to a logfile using python. I am creating the file just fine, but there is no input to the file that I am making.

here is my code:

import logging

log_file = '/home/user/Test.log'

form = "%(asctime)s - %(levelname)s - %(message)s"

logging.basicConfig(filename=log_file, filemode='w', level=logging.DEBUG , format=form)

logging.debug = ('DEBUG MESSAGE!')

Upvotes: 0

Views: 135

Answers (1)

Szabolcs
Szabolcs

Reputation: 4106

Well you need to change:

logging.debug = ('DEBUG MESSAGE!')

to

logging.debug('DEBUG MESSAGE!')

This way it should work!

Upvotes: 2

Related Questions