Example of how to use logging for both screen and file
Steve
lonetwin at gmail.com
Wed Oct 27 07:45:22 EDT 2004
Hi Vinay,
Firstly, thanks for such a nice and flexible module. It's got just
the kinda things one would expect of a logging module for large
applications. That said ....
> You've set up slog to only pass messages of INFO or
> higher, but you're logging a DEBUG message - lower
> than INFO, so it doesn't get logged.
Yup, I'm sorry about that, I noticed that only after I posted.
However, this too doesn't seem to work:
-------------------------------------------------------------------------------------
import logging, logging.handlers
def setupLogging():
global flog, slog
flog = logging.getLogger("mylog")
slog = logging.getLogger("mylog.slog")
flog.setLevel(logging.INFO)
slog.setLevel(logging.INFO)
filelog_hdlr = logging.FileHandler('/tmp/mylog')
syslog_hdlr = logging.handlers.SysLogHandler()
flog.addHandler(filelog_hdlr)
slog.addHandler(syslog_hdlr)
setupLogging()
flog.info("##################### foo #####################")
slog.info("################## info ####################")
slog.error("################## error ####################")
-------------------------------------------------------------------------------------
I know I must be missing something small. Could someone please try it out.
Regards
Steve
On Wed, 27 Oct 2004 11:36:26 +0100 (BST), Vinay Sajip
<vinay_sajip at yahoo.co.uk> wrote:
> > Could someone help me figure out what is wrong here
> > ?? I'd like to use
<snip>
More information about the Python-list
mailing list