Thanks, Peter for taking the time to respond. I need to study the reference further, & your comments pointed out some of my misconceptions. Thank you for clearing up some of my half-researched understanding.
Jim On Thu, Sep 1, 2011 at 10:53 PM, Peter Otten <__pete...@web.de> wrote: > James Hartley wrote: > > > I'm just needing to verify some behavior. > > > > Functionality within the logging module is exercised by calling functions > > defined within the module itself. I am using SQLAlchemy for database > > access, but it can be configured to dump out intermediate access > > information > > & queries to the logging module -- which is great. It really helps in > > debugging. > > > > However, if I want to write to a log which is separate from what > > SQLAlchemy is doing, am I correct stating that I will not be able to do > so > > through the logging module? > > > > Thanks for any insight which can be shared. > > Loggers are typically organized in a tree; sqlalchemy will probably log to > > logging.getLogger("sqlalchemy").warn("whatever") > > or something like > > logging.getLogger("sqlalchemy.some.sublogger").critical("test") > > You can prevent the rootlogger from seeing these messages with > > sq = logging.getLogger("sqlalchemy") > sq.propagate = False > > If for example you want to see messages in stdout by default, but write > SQLAlchemy's messages to a file you'd do (untested) > > import logging > import sys > logging.basicConfig(stream=sys.stdout) > > sq = logging.getLogger("sqalchemy") > sqhandler = logging.FileHandler("alchemy.log") > sqformatter = logging.Formatter(logging.BASIC_FORMAT) > sqhandler.setFormatter(sqformatter) > sq.addHandler(sqhandler) > sq.propagate = False > > sq.critical("alchemy") # goes to file alchemy.log > logging.getLogger("mine").critical("mine") # goes to stdout > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor