How come logging.error writes to a file, but not logging.debug or loggi

dcwhatthe at gmail.com dcwhatthe at gmail.com
Fri Mar 27 16:21:20 EDT 2020


On Friday, March 27, 2020 at 3:15:50 PM UTC-4, dcwhatthe wrote:
> Hi,
> 
> 
> When we run
> 
> 
>     logging.basicConfig( filename = "TestLogging_" +
> datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )
> 
> 
> , and then
> 
>     logging.error( "Test01\n" )
>     logging.debug("Test02\n")
>     logging.info("Test03\n")
>     logging.error( "Test04\n" )
> 
> 
> , only the error log lines get sent to the file.
> 
> 
> How do I get info() and debug() to go to the file, as well?

Got it.  Someone named Cameron, assisted with this.  For my purposes, I just needed to set the minimum level (INFO) inside the basic config function.  From there, the logging will take place for INFO and above, i.e. INFO, DEBUG, and ERROR in this case:


logging.basicConfig( filename = "TestLogging_" +
 datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log", level = logging.INFO )


Thanks, Cameron.


Regards,

DC



More information about the Python-list mailing list