WebFaction
Community site: login faq

Python newby question here:

I'm working on my first Python project here.

How do I log a debug message to my error.log file?

asked 22 Sep '11, 10:30

adamek
111
accept rate: 0%


CherryPy uses the logging module from Python's standard library.

Here are the logging settings. You use these by adding lines to your config file or dict.

log.screen: Set this to True to have both "error" and "access" messages printed to stdout.
log.access_file: Set this to an absolute filename where you want "access" messages written.
log.error_file: Set this to an absolute filename where you want "error" messages written.

Here is more on this in the CherryPy Documentation.

permanent link

answered 22 Sep '11, 10:43

timg ♦♦
1.3k4
accept rate: 30%

edited 22 Sep '11, 10:44

I've read that and already had those settings. Regular Python exceptions get written to the log files. How do I write a line of python code to send a message myself to that file? I don't quite grok the raise command yet.

(22 Sep '11, 11:02) adamek

From the CherryPy Logging doc:

Many events are automatically logged; to log your own application events, call cherrypy.log(msg, context='', severity=logging.DEBUG, traceback=False)

Set msg to the text that you want logged, then call that function.

(22 Sep '11, 12:21) seanf
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×32
×10

question asked: 22 Sep '11, 10:30

question was seen: 6,951 times

last updated: 22 Sep '11, 12:21

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM