Hi all,
I've apparently tied myself up a bit using the logging package.
In my project, I have a core set of model and controller classes that
set up their logging using logging.fileCon fig(). So far, so good.
But I use these core classes from a bunch of different places.
Sometimes from within a CherryPy server, sometimes batch jobs run from
a command line, sometimes from Windows services (also written in
Python). Ah, the beauty of OO design.
I would like to have a series of logs: a shared log for the core
classes (which would log messages from the core classes, regardless of
how they were invoked), a different one for CherryPy related stuff, a
third one for batch jobs run from the command line, a fourth for the
windows services. I'd alsolike to have the logs rotate automatically
using the TimedRotatingFi leHandler classes. Oh, and I'd like to do as
much setup thru the configuration files and logging.fileCon fig() as
possible.
So my questions are:
1) Can I share log files between processes? Log messages seem to get
written, but when it comes time to roll over a log, I generally get a
"IO operation on closed file" error. (I'm thinking that I may have to
set up a logging service if I want to do this, but I'm hoping there's a
simpler way.)
2) When I want to use logging from within a multi-threaded server
(built using the Threading module), do I create one global logger
reference, and then have each thread refer to that instance, or do I
have each thread grab it's own reference using getLogger()?
3) It seems like you can't make multiple calls to logging.fileCon fig().
If I call this twice with different ini files, it appears that any
handlers set up in the first call are silently dropped when the second
call is made. (Strangely, log messages sent to loggers set up in the
first call seem to just be silently dropped.) Am I diagnosing this
behavior properly? Is there a way
to work around it?
Platform is Python 2.4.2 on Windows.
Many thanks!
Chris 1 1691
Chris Curvey wrote: 1) Can I share log files between processes? Log messages seem to get written, but when it comes time to roll over a log, I generally get a "IO operation on closed file" error. (I'm thinking that I may have to set up a logging service if I want to do this, but I'm hoping there's a simpler way.)
For multi-process logging, I would advise that all processes use a
SocketHandler to send their events to a listener. You can use the
example code in the documentation at http://docs.python.org/lib/network-logging.html
to get a working example of a server which listens on a socket and
processes logging events received via the socket.
2) When I want to use logging from within a multi-threaded server (built using the Threading module), do I create one global logger reference, and then have each thread refer to that instance, or do I have each thread grab it's own reference using getLogger()?
Logger instances are singletons, so multiple calls to getLogger() with
a given name will always return the same instance. There's usually no
need to create a single global reference, though you could for example
create a logger as a class attribute in your Thread subclass (assuming
you're subclassing Thread), or an appopriate class which implements the
functionality which runs in different threads.
3) It seems like you can't make multiple calls to logging.fileCon fig(). If I call this twice with different ini files, it appears that any handlers set up in the first call are silently dropped when the second call is made. (Strangely, log messages sent to loggers set up in the first call seem to just be silently dropped.) Am I diagnosing this behavior properly? Is there a way to work around it?
fileConfig() is not meant to do incremental configurations, so it does
its best to disable any previous configuration.I t does this by clearing
out the list of previously defined handlers and disabling any
previously defined loggers. You can find the code easily enough and
comment it out if you wish not to disable old loggers.
Regards,
Vinay Sajip This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: alanrn |
last post by:
I would like to start a dialog on how to implement the equivalent
functionality of UNIX shared memory in .NET. I work with a factory
automation system. The bulk of the system is written in C/C++. It was
ported from UNIX to run under Windows using .NET. If for no other reason
than as an educational exercise, I have been wondering what it would take to
rewrite the system under C#.
The system currently has about a 100K “shared...
|
by: Gary Feldman |
last post by:
I didn't get any good answers to my previous question about unit testing,
so let me rephrase the question:
As near as I can see, it's possible to add arbitrary configurations to a C#
project in Visual Studio 2003. And it's possible to have multiple main
functions within a project (but not within a module), and use different
configurations to build different versions with different mains.
What I'm less clear about is how easy or...
|
by: David Wagner |
last post by:
Hi,
I am looking at wanting to configure and manage some
Performance Monitor logs through a C# application.
Specifically, I want to be able to define and configure
named performance log configurations and be able to start
and stop the logging through my application. I have done
some digging, but have not been able to figure how I would
do this from C#.
|
by: Philip Tepedino |
last post by:
I'm having an odd problem. My website's session state is getting shared
between users!
This problem only happens when a user tries to access the site from inside
our corporate LAN. The user, instead of getting a unique session ID, gets
somehow confused as another session and has access to all of the other
session's info!
I tried switching to cookieless sessions but that didn't make any
difference. This is a huge problem for me, since my...
|
by: Bob Day |
last post by:
VS 2003, vb.net , sql msde...
I have an application with multiple threads running. Its a telephony
application where each thread represents a telephone line. For code that
would be the same for each thread, I put in Shared methods as below. It is
only now that I am realizing the complexity of multiple threads accessing
shared methods. And, quite honestly, I am very confused.
I have tried System.Threading.Monitor.Enter, Synclock,...
| |
by: Rich Kucera |
last post by:
Holding all versions at 5.0.4, Multiple stacks with multiple-version
configurations inevitable
Will have to wait to see what the impact of problems such as
http://bugs.php.net/bug.php?id=33643 to the application world. We may
wait for a suitable popular resolution and jump to that version in the
future. There's already a rift between PHP4 and PHP5, and then further
developments such as these create another, splitting the camp into 4....
|
by: Dmitrii |
last post by:
My C# project has 4-configuration: Debug, Release, DebugPlus, and
ReleasePlus.
In each of these configurations the C# program should consume (be
"linked" to) a different Assembly.dll build created by a C++/CLI
multiple configuration project:: Debug, Release, DebugPlus, and
ReleasePlus Assembly.dll, respectively.
So far I could not find a way to do this.
|
by: eBob.com |
last post by:
I have this nasty problem with Shared methods and what I think of as "global
storage" - i.e. storage declared outside of any subroutines or functions.
In the simple example below this "global" storage is ButtonHasBeenClicked.
In this simple example code in Form1 calls a routine in Module1 which then
calls code back in Form1 (subroutine WhatEver). WhatEver needs to access
ButtonHasBeenClicked but the reference to ButtonHasBeenClicked...
|
by: Randy Shore |
last post by:
I have a shared Access mdb that was originally written in A2000. The
database is large, around 40 tables, 40 forms (many with multiple
sub-forms), and 100s of reports. The database is not split, but runs off of
the LAN in the office with about 5 or 6 concurrent users. Recently the
office upgraded to A2007 but they are continuing to run in compatability
mode.
The problem is that with ordinary use, read/write operations through the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |