Closed jiaeyan closed 5 years ago
program-y uses python logging. You therefore have a couple of option either
A) change the logging level to ERROR or even 0 and this will stop all output.
B) redirect logging output to a file
C) redirect logging output to /dev/null
All of these are done by changing logging.yaml.
For more info on the content of this file see Python logging documentation
Regards
Keith keith@keithsterling.com 07771 597630
On 13 Dec 2018, at 19:03, Jiajie Yan notifications@github.com wrote:
Hi Keifftser,
Currently I'm using program-y 2.2, and I am wondering is there any efficient way to mute all logging actions without touching the source code? For some reason I don't need them to either write to file or print to console. Thank you very much.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi Keith, Thank you very much for you detailed reply, and I will try as soon as possible. Best
I’m also updating the documentation over the next couple of days so will add a section to the logging page on how to mute with the various options
Regards
Keith keith@keithsterling.com 07771 597630
On 18 Dec 2018, at 18:32, Jiajie Yan notifications@github.com wrote:
Hi Keith, Thank you very much for you detailed reply, and I will try as soon as possible. Best
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
New logging documentation will be updated shortly, but the content is as follows
Program-Y using Python logging for all logging output. For a full description of how to specify logging configuration options see the Python Logging Documentation
The current logging file is as follows and is a good start which logs all output to /tmp/y-bot.log
version: 1
disable_existing_loggers: False
formatters:
simple:
format: '%(asctime)s %(name)-10s %(levelname)-7s %(message)s'
handlers:
file:
class: logging.handlers.RotatingFileHandler
formatter: simple
filename: /tmp/y-bot.log
root:
level: DEBUG
handlers:
- file
If for some reason you want to switch off logging then you have 2 options, either
Log to /dev/null on Linux as follows
version: 1
disable_existing_loggers: False
formatters:
simple:
format: '%(asctime)s %(name)-10s %(levelname)-7s %(message)s'
handlers:
file:
class: logging.handlers.RotatingFileHandler
formatter: simple
filename: /dev/null
root:
level: DEBUG
handlers:
- file
This is useful if you just want to switch off logging temporarily but switch back the file later
Alternatively use the NullHandler as follows
version: 1
disable_existing_loggers: False
formatters:
simple:
format: '%(asctime)s %(name)-10s %(levelname)-7s %(message)s'
handlers:
file:
class: logging.handlers.NullHandler
formatter: simple
root:
level: DEBUG
handlers:
- file
This being a more permanent solution
An alternative to changing where the output is written to is to change the logging level. In Python logging there are X levels
Where DEBUG is the most verbose and produces the most output an CRITICAL will only output the most major issues, usually when something catastrophic ( or critical ! ) has gone wrong and the application is about to terminate
Hi Keifftser,
Currently I'm using program-y 2.2, and I am wondering is there any efficient way to mute all logging actions without touching the source code? For some reason I don't need them to either write to file or print to console. Thank you very much.