logging and httphandler

J

Jason Friedman

I am logging to my Apache web server, using this Apache format:

LogFormat "%{%Y-%m-%d %H:%M:%S}t %U %q" scriptlog
CustomLog /var/log/apache2/script.log scriptlog

My code is as follows:

#!/usr/bin/env python3
import logging, logging.handlers, sys
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)
host = "localhost:9090"
url = "make_deployment_group"
http_handler = logging.handlers.HTTPHandler(host, url, method='GET')
http_formatter = logging.Formatter('%(name)s - %(levelname)8s - %(message)s')
http_handler.setFormatter(http_formatter)
logger.addHandler(http_handler)
logger.warn('warn message')

which results in a entry at /var/log/apache2/script.log:

2012-01-14 05:22:52
make_deployment_group?threadName=MainThread&name=simple_example&thread=139923654465280&created=1326518572.83&process=31122&processName=MainProcess&args=%28%29&module=my-logging&filename=my-logging.py&levelno=30&exc_text=None&pathname=my-logging.py&lineno=33&asctime=2012-01-14+05%3A22%3A52%2C825&msg=warn+message&exc_info=None&message=warn+message&funcName=%3Cmodule%3E&relativeCreated=20.0970172882&levelname=WARNING&msecs=825.411081314

All the information one could want, which is nice, but is there a way
to specify I want only certain information sent via the HTTP request?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top