473,586 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Daemon and logging - the best approach?

Hello.

I'm trying to make a daemon and I want to log to a file its activity.
I'm using logging module with a configuration file for it (loaded via
fileConfig()).

And now I want to read logging config file before daemonize the program
because the file might not be accessible after daemonization. OTOH while
daemonizing I am closing all opened file descriptors - including those
opened for logging.

What is the best approach to handle such situation? Should I close all
FD before daemonizing or just forget it? Any other hints?

Kind regards,

--
Lech Karol Paw³aszek <ike>
"You will never see me fall from grace" [KoRn]
Nov 7 '08 #1
5 2684
Lech Karol Pawłaszek <i@tak.znajdzie szwrites:
Hello.

I'm trying to make a daemon and I want to log to a file its activity.
I'm using logging module with a configuration file for it (loaded via
fileConfig()).

And now I want to read logging config file before daemonize the program
because the file might not be accessible after daemonization. OTOH while
daemonizing I am closing all opened file descriptors - including those
opened for logging.

What is the best approach to handle such situation? Should I close all
FD before daemonizing or just forget it? Any other hints?

Kind regards,
Depends.

For *NIX systems, it's a good idea to use the syslog daemon for logging
where it's available.

I believe the logging module can be configured to log to the local
syslog daemon.

Cheers.
Nov 7 '08 #2
J Kenneth King wrote:
[...]
Depends.

For *NIX systems, it's a good idea to use the syslog daemon for logging
where it's available.
True, however it's more convenient to have certain application logs in
its own place sometimes.
I believe the logging module can be configured to log to the local
syslog daemon.
Sure it can. I want to log to files though. Or at least I want to make
it configurable so one can choose a) log to files b) log via syslog.

I've found delay parameter for FileHandler, however it's only in 2.6 at
the moment and I need 2.5 and I am not so sure if it helps here. Tough life.

Kind regards,

--
Lech Karol Pawłaszek <ike>
"You will never see me fall from grace" [KoRn]
Nov 7 '08 #3
Lech Karol Pawłaszek wrote:
Hello.

I'm trying to make a daemon and I want to log to a file its activity.
I'm using logging module with a configuration file for it (loaded via
fileConfig()).

And now I want to read logging config file before daemonize the program
because the file might not be accessible after daemonization. OTOH while
daemonizing I am closing all opened file descriptors - including those
opened for logging.

What is the best approach to handle such situation? Should I close all
FD before daemonizing or just forget it? Any other hints?

Kind regards,
I use this, YMMV:

Nov 7 '08 #4
In message <gf**********@z eus.man.szczeci n.pl>, Lech Karol Pawłaszek wrote:
And now I want to read logging config file before daemonize the program
because the file might not be accessible after daemonization.
Why might it be inaccessible just because you've daemonized?
Nov 7 '08 #5
Lawrence D'Oliveiro wrote:
In message <gf**********@z eus.man.szczeci n.pl>, Lech Karol Pawłaszek wrote:
>And now I want to read logging config file before daemonize the program
because the file might not be accessible after daemonization.

Why might it be inaccessible just because you've daemonized?
Well. Just because I always thought one should close all file
descriptors while daemonizing a process.

Just like here:
http://code.activestate.com/recipes/278731/

Lines 160-164.

If one would like to keep logging configuration in a file (like me),
what is supposed to do? Not to close FDs? Or just start logging after
daemonizing (and know absolute location of the logging configuration file)?

Or maybe is there any way to close FD for a logfile, daemonize and
reopen FD again?

;-) Am I clear now?

Kind regards,

--
Lech Karol Pawłaszek <ike>
"You will never see me fall from grace" [KoRn]
Nov 7 '08 #6

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

Similar topics

8
1686
by: A.M | last post by:
Hi, What would be the best approach to log different items (SQL, Exceptions, Security, ...) I have a simple Logging function that adds log string to the end of a text file. Is there any application block for that? Should i do the logging into SQL server table ? Any help would be apprecited,
3
6409
by: Lowell Alleman | last post by:
Here is the situation: I wrote my own log handler class (derived from logging.Handler) and I want to be able to use it from a logging config file, that is, a config file loaded with the logging.config.fileConfig() function. Let say my logging class is called "MyLogHandler" and it's in a module called "mylogmodule", I want to be able to...
6
7573
by: Larry Bates | last post by:
Every time I look at the logging module (up until now) I've given up and continue to use my home-grown logger that I've been using for years. I'm not giving up this time ;-) I find that I REALLY need to be able to monitor LOTS of running programs/processes and thought it would be nice to have them use SocketHandler logging and then I...
6
1716
by: Thomas Heller | last post by:
I'm using the logging module in my comtypes library to log 'interesting' things that happen. In other words, the idea is if the user of the library is interested in the details that happen in the package internally, he (she?) would configure a logging level and handlers that write the log messages where it is convenient. This works great,...
0
7841
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...
0
8339
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...
1
7965
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...
0
8220
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...
0
6617
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...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1184
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...

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.