LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2006, 03:10 AM   #1
Chowroc
Member
 
Registered: Dec 2004
Posts: 145

Rep: Reputation: 15
python: logging can't log info level?


I wrote a python script:
Code:
      1 #!/usr/bin/python
      2 # -*- encoding: utf-8 -*-
      3 
      4 import logging
      5 
      6 syslogf = None
      7 
      8 def init(name='root'):
      9     global syslogf
     10     syslogf = logging.FileHandler('/var/log/tasks.log')
     11     syslogf.setLevel(logging.DEBUG)
     12     syslogf.setFormatter(logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s',
     13         '%Y-%m-%d,%H:%M:%S'))
     14 
     15     logger = logging.getLogger(name)
     16     logger.addHandler(syslogf)
     17     logger.info('debug test')
     18     # logger.warning('debug test')
     19     return logger
     20 
     21 def close():
     22     syslogf.close()
     23 
     24 init('test')
But only the 'warning', 'error' and 'critical' can be logged, why?

Thanks.
 
Old 05-01-2006, 12:48 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
I am getting the same results on my system. Perhaps syslog itself is trashing messages of lower severity than 'warning'.

Which logger are you using?
 
Old 05-07-2006, 03:57 AM   #3
Chowroc
Member
 
Registered: Dec 2004
Posts: 145

Original Poster
Rep: Reputation: 15
I add this line:
logger.setLevel(logging.INFO)

But I found anothor problem, do this:
l1 = logging.getLogger('same_name')
l1.info('something')
l2 = logging.getLogger('same_name')
l2.info('other things')

the result will be:
something
other things
other things

'other thing' repeats!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python: Logging into a site Baix Programming 26 04-30-2007 09:41 AM
Just wanting some info on Python epod69 Programming 7 06-25-2005 01:31 PM
log level of crond Berhanie Slackware 2 01-04-2005 11:04 PM
pppd logging to /var/log/ppp.log problem mrtwice Linux - Software 1 01-10-2004 05:38 PM
apache log level alaios Linux - Networking 1 12-08-2003 10:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration