Logging Configuration - sankhaMukherjee/RLalgos GitHub Wiki
Logging Configuration
Configuring the logger is done with the help of the configuration file config/config.json
. Specifically, the logging
key identifies all configuration associated with logging information within this file. An example if the logging
section is shown below. Details of the different sections will be described in the documentation that follows.
"logging":{
"logBase" : "RLalgos",
"level" : "INFO",
"specs" : {
"file":{
"todo" : true,
"logFolder": "logs"
},
"stdout":{
"todo" : false
},
"logstash":{
"todo" : false,
"version" : 1,
"port" : 5959,
"host" : "localhost"
}
}
}
"level"
Segment
The The logging module comes preconfigured to log at the "INFO"
level. However this can be set to one of the following levels, and is mapped to their respective logging levels.
'CRITICAL'
mapped tologging.CRITICAL
'ERROR'
mapped tologging.ERROR
'WARNING'
mapped tologging.WARNING
'INFO'
mapped tologging.INFO
'DEBUG'
mapped tologging.DEBUG
"specs"
Segment
The This module comes preconfigured for a number of logging sinks. The logs can go either to a logging file, to the stdout, or to logstash. Each section has a parameter "todo"
that will determine whether a particular sink shall be dded to the logging handler. The other parameters for each section is described below.
"specs.file"
Segment
The This segment is used for sending the logger output directly to a file. A base folder should be soecified within which the logging file should be generated. Each time the program is run, a new file is generated in the form YYYY-MM-DD_hh-mm-ss.log
. The default formatting string used is:
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
.
"specs.stdout"
Segment
The The output can potentially also be sent to the standard output if this section is turned on using the todo
key. By default, this section is turned off. The default formatting string used is:
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
.
"specs.logstash"
Segment
The It is also possible to use logstash as a sink. This is entirely JSON based. This uses TCP rather than the standard UDP. For configuring the logstash server, make sure to add the input:
tcp {
'port' => '5959'
'codec' => 'json'
}
The input port should match the port specified in the config/config.json
the config file. If your logstash is running on a different machine, make sure that you specify the host IP along with the port. An example output is shown:
{
"@timestamp" => 2018-08-12T03:49:25.212Z,
"level" => "ERROR",
"type" => "logstash",
"port" => 55195,
"@version" => "1",
"host" => "Sankha-desktop.local",
"path" => "/Users/user/Documents/programming/python/test/mytests/mnop/src/lib/testLib/simpleLib.py",
"message" => "Unable to add the two values [3] and [a]:\\nunsupported operand type(s) for +: 'int' and 'str'",
"tags" => [],
"logger_name" => "mnop.lib.simpleLib.simpleTestFunction",
"stack_info" => nil
}
This can then be sent to elasticsearch. If you need specific things filtered, you can directly use the filtering capabilities of logstash to generate this information.