Logging within a class

J

Joseph L. Casale

Within __init__ I setup a log with self.log = logging.getLogger('foo') then add a
console and filehandler which requires the formatting to be specified. There a few
methods I setup a local log object by calling getChild against the globallog object.


This works fine until I need to adjust the formatter for a few. With thisstyle, I need
to redefine the handlers, so basically setup logging again.


I tried to get around this by using basicConfig and simply re-specifying format inside
the few methods, but it didn't work.


How does one accomplish this most elegantly so I can define one log instance with
the appropriate general console and file handlers in my class, then simply override
the formatter for both handlers they use in a couple methods?


Thanks!
jlc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top