Re: PYTHON LOGGING with StreamHandler and FileHandler

2014-11-25 Thread Peter Otten
Ganesh Pal wrote: > Thanks for the hint , I was able to get the error messages on the console > by setting the StreamHandler level to WARNING . > > It works for me know butone LAST question , it might sound simple, > but Iam not able to understand the difference between > > - (a) ch

Re: PYTHON LOGGING with StreamHandler and FileHandler

2014-11-25 Thread Ganesh Pal
Thanks for the hint , I was able to get the error messages on the console by setting the StreamHandler level to WARNING . It works for me know butone LAST question , it might sound simple, but Iam not able to understand the difference between - (a) ch.setLevel(logging.WARNING) and c

Re: PYTHON LOGGING with StreamHandler and FileHandler

2014-11-24 Thread dieter
Ganesh Pal writes: > The below program logs all the messages to the log file and displays the > same on the console . > > Please suggest how do I ensure that error and warning log levels go ONLY to > stdout and/or stder You read the handler related documentation of the logging module. When I rem

Re: Python Logging and printf()

2014-11-24 Thread Ganesh Pal
Hi Chris, Thanks for the comments , Iam planning to use logging handlers ( StreamHandler and FileHandler) to achieve my requirement . Any quick reference example to this will be great , Iam on Python 2.7 , Iam referring the python docs for mow. Regards, Ganesh On Fri, Nov 21, 2014 at 5:25 PM, C

Re: Python Logging and printf()

2014-11-21 Thread Chris Angelico
On Fri, Nov 21, 2014 at 9:48 PM, Ganesh Pal wrote: > Please provide your input on the below questions. > > (1). How do i guarantee that all console messages will be logged into the > logfile ? > (2) I feel the need to retain few print(), how do I ensure the print() > messages are also logged int

Re: Python Logging and printf()

2014-11-21 Thread Stéphane Wirtel
On 21 Nov 2014, at 11:48, Ganesh Pal wrote: Hi Team , Iam using the python logging module to log the events for my application into a log file . I have set the logging level to DEBUG as shown below logging.basicConfig(filename=options.log_file, level=logging.DEBUG,

Re: Python Logging: Specifying converter attribute of a log formatter in config file

2012-09-16 Thread Vinay Sajip
On Thursday, August 30, 2012 11:38:27 AM UTC+1, Radha Krishna Srimanthula wrote: > > Now, how do I specify the converter attribute (time.gmtime) in the above > section? Sadly, there is no way of doing this using the configuration file, other than having e.g. a class UTCFormatter(logging.Format

Re: Python Logging: Specifying converter attribute of a log formatter in config file

2012-08-30 Thread bernhard . haslhofer
I have the same problem and couldn't find a solution. It seems that converters can only be set programmatically? On Thursday, August 30, 2012 6:38:27 AM UTC-4, Radha Krishna Srimanthula wrote: > I'd like to have all timestamps in my log file to be UTC timestamp. When > specified through code,

Re: python logging filter limitation, looks intentional?

2012-01-29 Thread Vinay Sajip
On Jan 28, 10:51 am, Chris Withers wrote: > To be clear, I wasn't asking for a change to existing behaviour, I was > asking for the addition of an option that would allow thelogging > framework to behave as most people would expect when it comes to filters ;-) And the evidence for "most people"

Re: python logging filter limitation, looks intentional?

2012-01-28 Thread Chris Withers
On 20/01/2012 20:09, Terry Reedy wrote: version upgrade. The proposed change isn't a new feature, it's a request for an existing feature to work differently. Thank you for the clarification. I had not gotten that the request was for a change, which has a much higher bar to pass than feature add

Re: python logging filter limitation, looks intentional?

2012-01-20 Thread Terry Reedy
On 1/20/2012 2:17 PM, Vinay Sajip wrote: On Jan 19, 12:50 am, Terry Reedy wrote: I don't want people to have to code differently for Python 3.3 and for older versions. This is not a general policy, else we would never add new features ;-) Do you plan to keep logging feature-frozen forever,

Re: python logging filter limitation, looks intentional?

2012-01-20 Thread Vinay Sajip
On Jan 19, 12:50 am, Terry Reedy wrote: > > >> I don't want people to have to code differently for Python 3.3 and for > >> older versions. > > This is not a general policy, else we would never add new features ;-) > Do you plan to keep logging feature-frozen forever, or just for another > release?

Re: python logging filter limitation, looks intentional?

2012-01-18 Thread Terry Reedy
On 1/18/2012 4:02 PM, Chris Withers wrote: On 17/01/2012 10:48, Vinay Sajip wrote: How about an option that defaults to "backwards compatibility mode" for Python 2.7, flipped the other way in 3.3? 2.7 only gets bug fixes, and this does not seem to be one. It's not a bug, because it's like

Re: python logging filter limitation, looks intentional?

2012-01-18 Thread Chris Withers
On 17/01/2012 10:48, Vinay Sajip wrote: From: Chris Withers How breaking code? Configuration, maybe, but I can't see anyone being upset that filtering would begin working "the same as everything else". This just feels like a bug... Well, it means that filters that don't get called now would

Re: python logging filter limitation, looks intentional?

2012-01-17 Thread Vinay Sajip
> From: Chris Withers > How breaking code? Configuration, maybe, but I can't see anyone being upset > that filtering would begin working "the same as everything else". > This just feels like a bug... Well, it means that filters that don't get called now would get called - and that's a change i

Re: python logging filter limitation, looks intentional?

2012-01-17 Thread Chris Withers
On 16/01/2012 23:21, Vinay Sajip wrote: Why is this? There must be some rationale for this rather than what, for me and others I've talked to, would seem more natural, ie: a filter on the root logger would get messages both logged to it and any messages propagated to it from child loggers to

Re: python logging module:a quick question

2011-12-27 Thread Lie Ryan
On 12/27/2011 05:26 PM, Littlefield, Tyler wrote: Hello all: I have a basic server I am working on, and wanted some input with an error I'm getting. I am initializing the logger like so: if __name__ == "__main__": observer = log.PythonLoggingObserver() observer.start() logging.basicConfig(filenam

Re: python logging multiple processes to one file (via socket server)

2011-10-27 Thread 88888 Dihedral
Well, please check the byte code compiled results. This is useful. I know that a lot people are working on increasing the speed of execution scripts written in python, say, psyco, pyrex for packages released! -- http://mail.python.org/mailman/listinfo/python-list

Re: python logging multiple processes to one file (via socket server)

2011-10-27 Thread bobicanprogram
On Oct 27, 6:09 am, Gelonida N wrote: > Hi, > > I have a rather 'simple' problem. > Logging from multiple processes to the same file AND be sure, that no > log message is lost, > > 1.) Log multiple processes to one file: > -- > > I have a python program, whi

Re: python logging multiple processes to one file (via socket server)

2011-10-27 Thread Vinay Sajip
On Oct 27, 11:09 am, Gelonida N wrote: > "The following section documents this approach in more detail and > includes a working socket receiver which can be used as a starting point > for you to adapt in your own applications." > > Somehow I have a mental block though and fail to see the 'followin

Re: python logging

2011-05-19 Thread Vinay Sajip
On May 18, 11:42 pm, Ian Kelly wrote: > I was wrong, it's more complicated than that. > > >>>logging.getLogger('log').warning('test') > > No handlers could be found for logger "log">>>logging.warning('test') > WARNING:root:test > >>>logging.getLogger('log').warning('test') > > WARNING:log:test > >

Re: python logging

2011-05-19 Thread Rafael Durán Castañeda
You are right that behavior isn't documented and might be a bug. You could report it. Bye El 19 de mayo de 2011 00:42, Ian Kelly escribió: > 2011/5/18 Ian Kelly : > > Ah, that's it. I was using Python 2.5. Using 2.7 I get the same > > result that you do. > > > > Still, it's a surprising chang

Re: python logging

2011-05-18 Thread Ian Kelly
2011/5/18 Ian Kelly : > Ah, that's it.  I was using Python 2.5.  Using 2.7 I get the same > result that you do. > > Still, it's a surprising change that doesn't seem to be documented as > such.  I'm not sure whether it's a regression or an intentional > change. I was wrong, it's more complicated t

Re: python logging

2011-05-18 Thread Ian Kelly
2011/5/18 Rafael Durán Castañeda : > Are you using python 2.x or 3.x? At python 2.7 using: > > import logging > logging.getLogger('log').warning('test') > > I got: > > No handlers could be found for logger "log" Ah, that's it. I was using Python 2.5. Using 2.7 I get the same result that you do.

Re: python logging

2011-05-18 Thread Vinay Sajip
On May 18, 11:10 pm, Ian Kelly wrote: > It seems to work without any configuration just as well as the root logger: > > >>> importlogging > >>>logging.getLogger('foo').warning('test') > > WARNING:foo:test > > Or am I misunderstanding you? In general for Python 2.x, the code import logging loggi

Re: python logging

2011-05-18 Thread Rafael Durán Castañeda
On 19/05/11 00:10, Ian Kelly wrote: 2011/5/18 Rafael Durán Castañeda: I think you are confuse because of you are looking at advanced logging, where getLogger is being used. Simple logging works without any configuration, getLogger doesn't. It seems to work without any configuration just as well

Re: python logging

2011-05-18 Thread Ian Kelly
2011/5/18 Rafael Durán Castañeda : > I think you are confuse because of you are looking at advanced logging, > where getLogger is being used. Simple logging works without any > configuration, getLogger doesn't. It seems to work without any configuration just as well as the root logger: >>> import

Re: python logging

2011-05-18 Thread Rafael Durán Castañeda
On 18/05/11 23:29, Ian Kelly wrote: 2011/5/18 Rafael Durán Castañeda: That's not exactly how it works. You can use logging without any configuration and the default output will be console. In addition default logging level is warning, so: logging.info("Some text") won't show anything and log

Re: python logging

2011-05-18 Thread Ian Kelly
2011/5/18 Rafael Durán Castañeda : > That's not exactly how it works. You can use logging without any > configuration and the default output will be console. In addition default > logging level is warning, so: > > logging.info("Some text") > > won't  show anything and > > logging.warning("Other tex

Re: python logging

2011-05-18 Thread Rafael Durán Castañeda
On 18/05/11 03:09, Fei wrote: On May 17, 6:55 pm, Ian Kelly wrote: On Tue, May 17, 2011 at 2:55 PM, Fei wrote: where is default logging file on Mac? I saw lots of app just import logging, and begins to logging.info(...) etc. I'm not sure where to look at the logging configuration to figure o

Re: python logging

2011-05-17 Thread Fei
On May 17, 6:55 pm, Ian Kelly wrote: > On Tue, May 17, 2011 at 2:55 PM, Fei wrote: > > where is default logging file on Mac? I saw lots of app just import > > logging, and begins to logging.info(...) etc.  I'm not sure where to > > look at the logging configuration to figure out the log location.

Re: python logging

2011-05-17 Thread Ian Kelly
On Tue, May 17, 2011 at 2:55 PM, Fei wrote: > where is default logging file on Mac? I saw lots of app just import > logging, and begins to logging.info(...) etc.  I'm not sure where to > look at the logging configuration to figure out the log location. There is no default log file. You're seeing

Re: python logging

2011-05-17 Thread Rafael Durán Castañeda
On 17/05/11 22:55, Fei wrote: where is default logging file on Mac? I saw lots of app just import logging, and begins to logging.info(...) etc. I'm not sure where to look at the logging configuration to figure out the log location. I just get in touch of python about 1month ago, and I appreciat

Re: python logging, handling multiline log entries

2010-11-04 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s")) l.error('1st line\n2n

Re: python logging writes an empty file

2010-03-26 Thread Ovidiu Deac
It worked. Setting disable_existing_loggers=False fixed my problem. Thanks to both of you! Ovidiu On Fri, Mar 26, 2010 at 9:09 PM, Vinay Sajip wrote: > On Mar 26, 4:26 pm, Ovidiu Deac wrote: >> Anyway, thanks for the first part. >> >> Anybody else has any idea why using the same configuration f

Re: python logging writes an empty file

2010-03-26 Thread Vinay Sajip
On Mar 26, 4:26 pm, Ovidiu Deac wrote: > Anyway, thanks for the first part. > > Anybody else has any idea why using the same configuration file works > when running the tests with nosetests and doesn't work > withlogging.config.fileConfig() ? It's probably because the fileConfig code is intended

Re: python logging writes an empty file

2010-03-26 Thread Ovidiu Deac
Anyway, thanks for the first part. Anybody else has any idea why using the same configuration file works when running the tests with nosetests and doesn't work with logging.config.fileConfig() ? -- http://mail.python.org/mailman/listinfo/python-list

Re: python logging writes an empty file

2010-03-26 Thread Jean-Michel Pichavant
Ovidiu Deac wrote: You set le level of your handler, but did not set the level of the logger itself. Replace file.setLevel(logging.INFO) by logging.getLogger().setLevel(logging.INFO) Log events are matched versus the logger level 1st, then the handler level (if applicable). Most of the time you

Re: python logging writes an empty file

2010-03-26 Thread Ovidiu Deac
> You set le level of your handler, but did not set the level of the logger > itself. > Replace file.setLevel(logging.INFO) by > logging.getLogger().setLevel(logging.INFO) > > Log events are matched versus the logger level 1st, then the handler level > (if applicable). Most of the time you don't ne

Re: python logging writes an empty file

2010-03-26 Thread Jean-Michel Pichavant
Ovidiu Deac wrote: Then I tried this: file = logging.FileHandler(logFileBasename, 'w') file.setLevel(logging.INFO) # set a format which is simpler for console use formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s',) # tell the handler to use th

Re: python logging filters

2009-11-30 Thread Grimsqueaker
My logging behaves as I expect now and I have a better understanding of how the module functions. Thank you for taking the time to explain those points to me. :) On Nov 30, 4:10 pm, Vinay Sajip wrote: > On Nov 30, 6:52 am, Grimsqueaker wrote: > > > > > So would I be correct in saying that Filter

Re: python logging filters

2009-11-30 Thread Grimsqueaker
My logging behaves as I expect now and I have a better understanding of how the module functions. Thank you for taking the time to explain those points to me. :) On Nov 30, 4:10 pm, Vinay Sajip wrote: > On Nov 30, 6:52 am, Grimsqueaker wrote: > > > > > So would I be correct in saying that Filter

Re: python logging filters

2009-11-30 Thread Grimsqueaker
My logging behaves as I expect now and I have a better understanding of how the module functions. Thank you for taking the time to explain those points to me. :) On Nov 30, 4:10 pm, Vinay Sajip wrote: > On Nov 30, 6:52 am, Grimsqueaker wrote: > > > > > So would I be correct in saying that Filter

Re: python logging filters

2009-11-30 Thread Vinay Sajip
On Nov 30, 6:52 am, Grimsqueaker wrote: > > So would I be correct in saying that Filters apply only the the object > they are attached to and have no effect on how messages are propagated > through thelogginghierarchy? If this is the case my next question > would be: How can I affect whether or no

Re: python logging filters

2009-11-29 Thread Grimsqueaker
On Nov 30, 8:42 am, Grimsqueaker wrote: > On Nov 28, 11:26 am, Vinay Sajip wrote: > > > > > On Nov 27, 1:11 pm, Grimsqueaker wrote: > > > > When I add a Filter to a Handler, everything works as expected (ie. > > > all messages sent from Loggers below the Filter's level are allowed > > > through)

Re: python logging filters

2009-11-29 Thread Grimsqueaker
On Nov 30, 8:42 am, Grimsqueaker wrote: > On Nov 28, 11:26 am, Vinay Sajip wrote: > > > > > On Nov 27, 1:11 pm, Grimsqueaker wrote: > > > > When I add a Filter to a Handler, everything works as expected (ie. > > > all messages sent from Loggers below the Filter's level are allowed > > > through)

Re: python logging filters

2009-11-29 Thread Grimsqueaker
On Nov 28, 11:26 am, Vinay Sajip wrote: > On Nov 27, 1:11 pm, Grimsqueaker wrote: > > > When I add a Filter to a Handler, everything works as expected (ie. > > all messages sent from Loggers below the Filter's level are allowed > > through), but when I add the Filter directly on to the Logger, on

Re: python logging filters

2009-11-28 Thread Vinay Sajip
On Nov 27, 1:11 pm, Grimsqueaker wrote: > When I add a Filter to a Handler, everything works as expected (ie. > all messages sent from Loggers below the Filter's level are allowed > through), but when I add the Filter directly on to the Logger, only > that Logger is blocked, regardless of the cont

Re: Python logging and 1.5.2 compatibility

2009-09-30 Thread Aahz
In article , Vinay Sajip wrote: > >I'm planning to "officially" drop support for Python 1.5.2 in the logging >package. Sounds good -- posting publicly about it is definitely appreciated. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "Normal is what cuts o

Re: Python logging and 1.5.2 compatibility

2009-09-30 Thread TerryP
On Sep 30, 1:26 pm, Vinay Sajip wrote: > > A 1.5.2-compatible version of the package is still available > viahttp://www.red-dove.com/python_logging.htmlif anyone needs it. This version > is not actively maintained, but that shouldn't be an issue. > > Regards, > > Vinay Sajip As long as people ca

Re: Python logging rollover

2009-01-12 Thread Scott David Daniels
Kottiyath wrote: Hi, I want to do a log rollover I tested it with 'midnight' option, but it did not work as I expected. Please google "smart questions". All I can conclude from your message is that your expectations are wrong. It is not enough to tell us you are confused. You need to sh

Re: Python logging question

2009-01-02 Thread koranthala
On Jan 2, 6:21 pm, Vinay Sajip wrote: > On Jan 2, 11:31 am, koranth...@gmail.com wrote: > > >     I am confused reading both together. I will try to explain my > > confusion with an example: > > > basicLogger =logging.getLogger("basic") > > > Class A(): > >   def __init__(self): > >      self.logg

Re: Python logging question

2009-01-02 Thread Vinay Sajip
On Jan 2, 11:31 am, koranth...@gmail.com wrote: > I am confused reading both together. I will try to explain my > confusion with an example: > > basicLogger =logging.getLogger("basic") > > Class A(): > def __init__(self): > self.logger =logging.getLogger("basic.class_a") > >Now, I ma

Re: Python logging and ThreadingTCPServer

2008-10-17 Thread Vinay Sajip
On Oct 17, 5:48 pm, Daniel <[EMAIL PROTECTED]> wrote: > Hello, > > I building an application that consists of several sockets > components. I would like to useloggingin them, but I've noticed > some issues with the logs getting mangled. This mangling seems to > happen when different threads attem

Re: Python logging: Retrieving the last log record from a handler

2008-03-04 Thread Vinay Sajip
On Mar 3, 11:41 am, Frank Aune <[EMAIL PROTECTED]> wrote: > I will be fairly surprised if this functionality is not already built-in for > the defaultlogginghandlers, but so far I've been unable to figure out how > to pull it of without the custom loghandler above. Prepare to be surprised ;-) Exc

Re: python logging config file doesn't allow filters?

2007-10-29 Thread Vinay Sajip
On 26 Oct, 17:23, Matthew Wilson <[EMAIL PROTECTED]> wrote: > I'm studying > filters and the config-file approach. Is it possible to define a filter > somehow and then refer to it in my config file? I'm afraid not. There's currently no support for filters in the configuration file format, and no

Re: python logging module and custom handler specified in config file

2007-10-19 Thread Vinay Sajip
On 19 Oct, 12:04, Frank Aune <[EMAIL PROTECTED]> wrote: > On Thursday 18 October 2007 19:26:59 Vinay Sajip wrote: > > What if you want to datestamp filenames for filehandlers, say with todays date > for example? > > [handler_file] > class=FileHandler > level=NOTSET > formatter=normal > args=('filen

Re: python logging module and custom handler specified in config file

2007-10-19 Thread Frank Aune
On Thursday 18 October 2007 19:26:59 Vinay Sajip wrote: > The values in the config file are interpreted in the context of the > logging module's namespace. Hence, one way of achieving what you want > is putting any custom handlers in > a module of your own, and providing a binding in the logging mo

Re: python logging module and custom handler specified in config file

2007-10-18 Thread Frank Aune
On Thursday 18 October 2007 19:26:59 Vinay Sajip wrote: > The same technique applies to the arguments passed to the constructor. > > Hope this helps, > Thank you! This seems like exactly what I was looking for. Very impressive logging framework btw - I use it whenever I can =) Cheers, Frank --

Re: python logging module and custom handler specified in config file

2007-10-18 Thread Vinay Sajip
On 15 Oct, 15:15, Frank Aune <[EMAIL PROTECTED]> wrote: > What I'm wondering, is if its possible to specify the database handler in a > config file like: > > [handler_database] > class=DBHandler > level=DEBUG > formatter=database > args=('localhost', uid='root') > > I've seen the log_test14.py exam

Re: python logging module problem

2006-07-14 Thread Ritesh Raj Sarraf
Peter Otten wrote: > You can achieve the desired behaviour by adding a custom Filter: > > import sys > import logging > > logger = logging.getLogger("my_app") > logger.setLevel(logging.DEBUG) > > class LevelFilter(logging.Filter): > def __init__(self, level): > self.level = level >

Re: python logging module problem

2006-07-14 Thread Peter Otten
Ritesh Raj Sarraf wrote: > Vinay Sajip wrote: >> It's usual to rely on logger levels and to set handler levels for >> additional refinement of what goes to a particular handler's >> destination. > The problem is that for StreamHandler, logging module logs to > sys.stderr. > I want to use the lo

Re: python logging module problem

2006-07-14 Thread Ritesh Raj Sarraf
Vinay Sajip wrote: > > It's usual to rely on logger levels and to set handler levels for > additional refinement of what goes to a particular handler's > destination. > The problem is that for StreamHandler, logging module logs to sys.stderr. I want to use the logging feature for most of the mess

Re: python logging module problem

2006-07-14 Thread Vinay Sajip
Ritesh Raj Sarraf wrote: > When I execute the above code, logger.info()'s messages don't get > displayed. And logger.warning()'s messages get displayed twice. > The warning messages are displayed twice because you have two handlers which both output to the console. The reason you don't get the i

Re: python logging module problem

2006-07-13 Thread Ritesh Raj Sarraf
Ritesh Raj Sarraf wrote: > import os, sys, logging > > logger = logging.getLogger("my_app") > I tried this code: import logging, sys # set up logging to file - see previous section for more details logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(le