The basic idea of logging:
Message filtering during the 1 and 2 stages does not take time. Filtering during the stage 4 takes a way much more time. Therefore, it is recommended to apply filtering only if it is crucial.
Logging configuration:
| Content | Description | |
|---|---|---|
"Logging": { | ||
"Loggers": { | Contains the list of loggers for the various program components, where the key is a logger name, the value is a logging level. Logger separation is performed for fine-tuning messages to be logged:
Possible logging levels (Severity):
| |
"Root": "debug" | Root logger, responsible for reading DB records, indexes creating, archiving, indexes deleting | |
}, | ||
"Core": { | Logging kernel general settings | |
"DisableLogging": false | Capability to disable logging in the component. Disabling after the first 3 stages of the message transfer through the logging system, since these stages are performed outside of the logging system and are not controlled by this setting | |
}, | ||
"Backends": { | Backends list | |
"DefaultDirectory": "/var/log/infowatch/", | Default directory for logging to a file | |
"ActiveBackends": [ | Active backends list. The backends, that are on the list, are considered for logging | |
"Console", | Console output (if the process is not launched as daemon, otherwise logs will be saved to /dev/null). The fastest backend | |
"Syslog", | System log output (/var/log/messages). The slowest backend | |
"File" | Specified text file output (directory for a file to be created is specified in the parameter DefaultDirectory). Relatively slow backend | |
], | ||
"Descriptions": { | Possible backend descriptions list, where the key is a backend name, the value is a backend description object. This list only describes backends. To make a backend active, add it to the list ActiveBackends | |
"Syslog": { | System log output description | |
"Destination": "Syslog", | Backend type | |
"Asynchronous": false, | Asynchronous backend or not. The asynchronous mode implies the message will be recorded after the message is processed by the logging system (the message will be enqueued and sent to console/syslog/file at some time). This means, if the System hangs up immediately after the message is processed by the logging system, there is a high possibility that the message to never be logged. The pro of the asynchronous mode is faster message processing (the main code of the program spends less time processing messages). It makes sense to set true, when it is necessary to have intensive logging, and the program performance does not raise questions. Otherwise, false should be set. | |
"Format": "%LineID% (%ProcessID%:%ThreadID%) [%Severity%] : <%Channel%> %Message%" | Message formatting rules. Key words for formatting and filtering:
| |
"Console": { | Console output description | |
"AutoFlush": true, | Screen output or awaiting in the buffer. The false parameter gives the same result as Asynchronous=true (see above) | |
"Destination": "Console", | Backend type | |
"Asynchronous": false, | Asynchronous backend or not | |
"Format": "%LineID% %TimeStamp% (%ProcessID%:%ThreadID%) [%Severity%] : <%Channel%> %Message%" | Message formating rules | |
}, | ||
"File": { | Specified text file output description | |
"Format": "%LineID% %TimeStamp% (%ProcessID%:%ThreadID%) [%Severity%] : <%Channel%> %Message%", | Message formating rules | |
"Destination": "TextFile", | Backend type | |
"FileName": "adlibitum.log", | File name, where log will be written in | |
"AutoFlush": true, | Screen output or awaiting in the buffer. The false parameter gives the same result as Asynchronous=true. Setting rules are the same (but invertible). | |
"Asynchronous": false, | Asynchronous backend or not | |
"Append": true | Add message to an old file or create a new file at the program startup | |
} | ||
} | ||
}, | ||
"SuppressExceptions": false, | Suppress exceptions in the logging mechanism | |
"GlobalLevel": "warning" | Global logging level. Recommended value when implementing – error. This level enables logging messages with the level error or higher (fatal). Normal operation value and by default - warning, i.e. only errors and warnings are written in logs. It is not recommended to use the trace value without special purpose |