Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Python root logger store a log?

I'm using the Freebase Python library. It creates a log before executing:

self.log = logging.getLogger("freebase") 

Where is this log in the file system? It's not in the executing directory or tmp.

like image 381
Matt Norris Avatar asked Oct 28 '10 11:10

Matt Norris


People also ask

Where does Python logger store logs?

That call does not store anything. It merely creates a logger object which can be bound and configured however you would like. All warnings and errors would be logged to the standard output (that's what basicConfig does), including the calls that Freebase makes.

Where does logger info write to Python?

We can also use the logging. FileHandler() function to write logs to a file in Python. This function takes the file path where we want to write our logs. We can then use the addHandler() function to add this handler to our logger object.

Where does logging logger write to?

For example, if you have configured the root logger to log messages to a particular file. You also have a custom logger for which you have not configured the file handler to send messages to console or another log file. In this case, the custom logger will fallback and write to the file set by the root logger itself.


1 Answers

That call does not store anything. It merely creates a logger object which can be bound and configured however you would like.

So if in your Python code, you were to add

logging.basicConfig(level=logging.WARNING) 

All warnings and errors would be logged to the standard output (that's what basicConfig does), including the calls that Freebase makes. If you want to log to the filesystem or other target, you'll want to reference the logging module documentation for more information. You may also wish to reference the Logging HOWTO.

like image 174
Jason R. Coombs Avatar answered Sep 20 '22 14:09

Jason R. Coombs