Configuring Logging


CellProfiler prints diagnostic messages to the console by default. You can change this behavior for most messages by configuring logging. The simplest way to do this is to use the command-line switch, "-L", to set the log level. For instance, to show error messages or more critical events, start CellProfiler like this:
CellProfiler -L ERROR
The following is a list of log levels that can be used:
You can tailor CellProfiler's logging with much more control using a logging configuration file. You specify the file name in place of the log level on the command line, like this:
CellProfiler -L ~/CellProfiler/my_log_config.cfg
Files are in the Microsoft .ini format which is grouped into categories enclosed in square brackets and the key/value pairs for each category. Here is an example file:
[loggers]
keys=root,pipelinestatistics

[handlers]
keys=console,logfile

[formatters]
keys=detailed

[logger_root]
level=WARNING
handlers=console

[logger_pipelinestatistics]
level=INFO
handlers=logfile
qualname=pipelineStatistics
propagate=0

[handler_console]
class=StreamHandler
formatter=detailed
level=WARNING
args=(sys.stderr)

[handler_logfile]
class=FileHandler
level=INFO
args=('~/CellProfiler/logfile.log','w')

[formatter_detailed]
format=[%(asctime)s] %(name)s %(levelname)s %(message)s
datefmt=
The above file would print warnings and errors to the console for all messages but "pipeline statistics" which are configured using the pipelineStatistics logger are written to a file instead.. The pipelineStatistics logger is the logger that is used to print progress messages when the pipeline is run. You can find out which loggers are being used to write particular messages by printing all messages with a formatter that prints the logger name ("%(name)s").
The format of the file is described in greater detail here.