473,594 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NTEventLogHandl er not logging `info'?

This code doesn't seem to do what I think it should do:

# python 2.3.2
# not sure of my win32 extensions version

import logging
from logging.handler s import NTEventLogHandl er
logger = logging.getLogg er("testlogger" )
handler = NTEventLogHandl er("testlogger" )
logger.addHandl er(handler)
logger.info("Th is is a test")
I expected to see an `information' message in my `Application' event
log. Any ideas?

Thanks,
jw
Sep 22 '05 #1
5 2454
Jaime Wyant wrote:
This code doesn't seem to do what I think it should do:

# python 2.3.2
# not sure of my win32 extensions version

import logging
from logging.handler s import NTEventLogHandl er
logger = logging.getLogg er("testlogger" )
handler = NTEventLogHandl er("testlogger" )
logger.addHandl er(handler)
logger.info("Th is is a test")
I expected to see an `information' message in my `Application' event
log. Any ideas?


By default, the logger's level is WARNING, because you haven't
explicitly set a level and the level inherited from the parent logger
is WARNING (this is the default value for the root logger level). So if
you add a line before the logger.info() call:

logger.setLevel (logging.INFO) # or you can use logging.DEBUG

Then you should see an entry appear in the NT Event log.

Sep 22 '05 #2
I must be missing something. This is what I read from the documentation:

When a logger is created, the level is set to NOTSET (which causes all
messages to be processed in the root logger, or delegation to the
parent in non-root loggers).

:/

Thanks!
jw

On 22 Sep 2005 08:21:48 -0700, Vinay Sajip <vi*********@ya hoo.co.uk> wrote:
Jaime Wyant wrote:
This code doesn't seem to do what I think it should do:

# python 2.3.2
# not sure of my win32 extensions version

import logging
from logging.handler s import NTEventLogHandl er
logger = logging.getLogg er("testlogger" )
handler = NTEventLogHandl er("testlogger" )
logger.addHandl er(handler)
logger.info("Th is is a test")
I expected to see an `information' message in my `Application' event
log. Any ideas?


By default, the logger's level is WARNING, because you haven't
explicitly set a level and the level inherited from the parent logger
is WARNING (this is the default value for the root logger level). So if
you add a line before the logger.info() call:

logger.setLevel (logging.INFO) # or you can use logging.DEBUG

Then you should see an entry appear in the NT Event log.

--
http://mail.python.org/mailman/listinfo/python-list

Sep 22 '05 #3
BTW - you're suggestion worked.

Thanks again!
jw

On 9/22/05, Jaime Wyant <pr***********@ gmail.com> wrote:
I must be missing something. This is what I read from the documentation:

When a logger is created, the level is set to NOTSET (which causes all
messages to be processed in the root logger, or delegation to the
parent in non-root loggers).

:/

Thanks!
jw

On 22 Sep 2005 08:21:48 -0700, Vinay Sajip <vi*********@ya hoo.co.uk> wrote:
Jaime Wyant wrote:
This code doesn't seem to do what I think it should do:

# python 2.3.2
# not sure of my win32 extensions version

import logging
from logging.handler s import NTEventLogHandl er
logger = logging.getLogg er("testlogger" )
handler = NTEventLogHandl er("testlogger" )
logger.addHandl er(handler)
logger.info("Th is is a test")
I expected to see an `information' message in my `Application' event
log. Any ideas?


By default, the logger's level is WARNING, because you haven't
explicitly set a level and the level inherited from the parent logger
is WARNING (this is the default value for the root logger level). So if
you add a line before the logger.info() call:

logger.setLevel (logging.INFO) # or you can use logging.DEBUG

Then you should see an entry appear in the NT Event log.

--
http://mail.python.org/mailman/listinfo/python-list

Sep 22 '05 #4
Jaime Wyant wrote:
I must be missing something. This is what I read from the documentation:

When a logger is created, the level is set to NOTSET (which causes all
messages to be processed in the root logger, or delegation to the
parent in non-root loggers).


The documentation could be clearer, I agree. I will add the following
clarifying sentence to the docs:

The term "delegation to the parent" means that if a logger has a level
of NOTSET, its ancestor loggers are examined until the root is reached,
or an ancestor with a level other than NOTSET is found. In the latter
case, that level is treated as the effective level of the logger where
the ancestor search started, and is used to determine how a logging
event is handled. If the root is reached, and it has a level of NOTSET,
then all messages will be processed. Otherwise, the root's level will
be used as the effective level.

Please post a response on the list if you think the above is still not
clear enough.

Sep 22 '05 #5
On 22 Sep 2005 12:23:50 -0700, Vinay Sajip <vi*********@ya hoo.co.uk> wrote:
Jaime Wyant wrote:
I must be missing something. This is what I read from the documentation:

When a logger is created, the level is set to NOTSET (which causes all
messages to be processed in the root logger, or delegation to the
parent in non-root loggers).


Thanks for your attentiveness!
The documentation could be clearer, I agree. I will add the following
clarifying sentence to the docs:

The term "delegation to the parent" means that if a logger has a level
of NOTSET, its ancestor loggers are examined until the root is reached,
or an ancestor with a level other than NOTSET is found. In the latter
case, that level is treated as the effective level of the logger where
the ancestor search started, and is used to determine how a logging
event is handled. If the root is reached, and it has a level of NOTSET,
then all messages will be processed. Otherwise, the root's level will
be used as the effective level.

Please post a response on the list if you think the above is still not
clear enough.


After re-reading the documentation I posted originally, it makes much
more sense and I feel much more stupid *smacks self in head*. Your
definition of "delegation of the parent" is right on the mark, however
I found myself having to read it a few times to have it `sink in'.

I've rewritten it below in a bit easier to read fashion (I think).

The term "delegation to the parent" means that if a logger has a level
of NOTSET, its chain of ancestor loggers are traversed until an
ancestor with a level other than NOTSET is found or the root is
reached.

If an ancestor is found with a level other than NOTSET, then that
ancestor's level is treated as the effective level of the logger where
the ancestor search began, and is used to determine how a logging
event is handled.

If the root is reached, and it has a level of NOTSET, then all
messages will be processed. Otherwise, the root's level will be used
as the effective level.

HTH,
jw
Sep 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1309
by: Marek Augustyn | last post by:
Hello, I'm getting strange exception raised using module logging. It's strange because it happens only sometimes, and it happens in different places (but always in a logging method). i.e. this line of code: log.info('SMS sent') produces following traceback:
6
10869
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to dump "info" level (and up) log information to screen, and "debug" level (and up) to a log file for in-depth analysis. This is for scripts, so date/time/severity information is not wanted. I assumed such a simple use case would have an example in the docs (py 2.4), but no luck.
0
1674
by: Neil Benn | last post by:
Hello, I'm running a test and having issues with logging, if I call logging.shutdown() and then want to start the logging going again then I get a problem as if I call shutdown, I can't get the root logger again, such as : ..>>> import logging ..>>> objTestLogger = logging.getLogger() ..>>> objTestLogger.setLevel(logging.INFO)
1
3662
by: jjesso | last post by:
I am trying to add a new logging level. logging.config.fileConfig("bengineLog.cfg") logging.CLIENT = logging.INFO + 1 logging.addLevelName( logging.CLIENT, 'CLIENT' ) logging.root.setLevel( ) logger = logging.getLogger(None) logging.Logger.client('test') I get error:
3
1444
by: olsongt | last post by:
I'm trying to be a good boy and use the logging module but it's behaving rather counter-intuitively. I've posted a simplified test script below. To summarize, I've set the basic config to only log root level messages with >= ERROR level. I've created another named logger that logs on info level. I've set it up so it just shows the message text without "INFO:: logger:" boilerplate. The way I see things, when I call otherLogger.info,...
23
2207
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field %(function)s, which results in the name of the entity which logged the record. My version even deduces the class name in the case which the logger is a bound method, and assuming the name of the "self" variable is indeed "self".
7
2417
by: Jed Parsons | last post by:
Hi, I'm using the logging module for the first time. I'm using it from within Zope Extensions. My problem is that, for every event logged, the logger is producing multiple identical entries with the timestamp the same down to the millisecond. Is this something I'm doing wrong?
3
1602
by: seb | last post by:
Hi, I am writing to a file some basic information using the logging module. It is working but in the log file some line are printed several time. I had put some print debugging messages in the logging function (so they appear on the consile) and they are called once only. Obviously there is some understantding of the logging module that I am missing. My simple logging program (see below) is called by several processes. In this way I...
12
1915
by: Eric S. Johansson | last post by:
I need to to be able to conditionally log based on the method the log statement is in and one other factor like a log level. in order to do so, I need to be able to automatically find out the name of the method and its class but I haven't found out how to do that yet. for example, class catus(Felis): def Siamese_cat( yowl, purr, demand_food):
0
8253
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8009
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8240
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1482
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.