Add logging configuration #3460
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides a number of options for controlling how InvokeAI logs messages, including options to log to a file, syslog and a web server. Several logging handlers can be configured simultaneously.
Controlling How InvokeAI Logs Status Messages
InvokeAI logs status messages using a configurable logging system. You can log to the terminal window, to a designated file on the local machine, to the syslog facility on a Linux or Mac, or to a properly configured web server. You can configure several logs at the same time, and control the level of message logged and the logging format (to a limited extent).
Three command-line options control logging:
--log_handlers <handler1> <handler2> ...This option activates one or more log handlers. Options are "console", "file", "syslog" and "http". To specify more than one, separate them by spaces:
The format of these options is described below.
--log_format {plain|color|legacy|syslog}This controls the format of log messages written to the console. Only the "console" log handler is currently affected by this setting.
"color" produces similar output, but the text will be color coded to indicate the severity of the message.
"legacy" produces output similar to InvokeAI versions 2.3 and earlier:
(note that the date, time and hostname will be added by the syslog system)
--log_level {debug|info|warning|error|critical}Providing this command-line option will cause only messages at the specified level or above to be emitted.
Console logging
When "console" is provided to
--log_handlers, messages will be written to the command line window in which InvokeAI was launched. By default, the color formatter will be used unless overridden by--log_format.File logging
When "file" is provided to
--log_handlers, entries will be written to the file indicated in the path argument. By default, the "plain" format will be used:Syslog logging
When "syslog" is requested, entries will be sent to the syslog system. There are a variety of ways to control where the log message is sent:
/dev/logsocket:This can be abbreviated
syslog=loghost, as LOG_USER and SOCK_DGRAM are defaults.If no arguments are specified (just a bare "syslog"), then the logging system will look for a UNIX socket named
/dev/log, and if not found try to send a UDP message tolocalhost. The Macintosh OS used to support logging to a socket named/var/run/syslog, but this feature has since been disabled.Web logging
If you have access to a web server that is configured to log messages when a particular URL is requested, you can log using the "http" method:
The optional [,method=] part can be used to specify whether the URL accepts GET (default) or POST messages.
Currently password authentication and SSL are not supported.
Using the configuration file
You can set and forget logging options by adding a "Logging" section to
invokeai.yaml: