logging.getLogger( __name__ )

R

Ram

How does this line work? How do I get my logger to point to a file to
be named as /tmp/modulename.log : I can do this using inspect, but
there probably is a better way?

Thanks,
--Ram
 
D

Dennis Lee Bieber

How does this line work? How do I get my logger to point to a file to
be named as /tmp/modulename.log : I can do this using inspect, but
there probably is a better way?
Uhm... by defining a file-handler and supplying the name to it?

All you've done with (I presume an assignment):

myLogger = logging.getLogger(__name__)

is to create a "logger" which will prefix log messages with the module
name. The default destination is probably still stderr.

See:
See 15.7.14.2 in the library reference manual for defining filehandlers;
15.7.1.1 for a sample using basic configuration and setting a default
file (the file will be common to all loggers I believe).
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top