Search code examples
pythonfilehttp-redirectloggingpyramid

How to redirect error logs to a particular file in python pyramid framework


I want to redirect all the logs for my web app to a particular log file

I am looking for one common setting ( code/ini ) that can re-direct all the logs for my app to a particular file.


Solution

  • You should be able to use the regular python logging handlers to set up file logging. See Pyramid's docs and the Python docs. For example, here's part of a logger config I've used to set up a rotating file log on the file system:

    [handler_filelog]
    class = logging.handlers.TimedRotatingFileHandler
    args = ('/path/to/mylog.log','D', 1, 15)
    level = NOTSET
    formatter = generic