Logging with 2 process in application

gayatri funde fundegayatri at gmail.com
Mon Feb 22 00:46:57 EST 2021


On Monday, February 22, 2021 at 10:49:36 AM UTC+5:30, Chris Angelico wrote:
> On Mon, Feb 22, 2021 at 4:11 PM gayatri funde <fundeg... at gmail.com> wrote: 
> > 
> > Hello, 
> > 
> > Greetings!! Have a good day! 
> > 
> > This is regarding logging issue i am facing in my application. My requirement is to create log on daily basis while my application is running, So to do this i am creating new log file at midnight by comparing the day it starts and enter to new day with the while loop continuously checking on date. 
> > 
> > In my application i have 2 processes, So what my observation is on the day of start of application both process are able to log into the file, but as new day starts new file getting created and only main process log are getting written into new file, and other process is still writing to old day log. 
> > 
> > So could you please help me to understand this issue and it will be great to know solution if you can help me with this. 
> >
> What makes the decision to create a new file? How is that done? If 
> you're closing the old one and opening a new one, both processes will 
> have to do it; if you're renaming it away and then closing and opening 
> with the same name, one process has to do the rename, and then the 
> other has to just close/open. 
> 
> It may be easier and cleaner to make use of a separate logging 
> facility. Many operating systems come with them. 
> 
> ChrisA


By checking the new day start continuously, I am able to create new file before that i am clearing old day file handler. My doubt is Main process able to find the new day file handler but why not the other process. And before creating new file handler, i am clearing old file handler. So how other process is still have access to old day File handler. I am having little confusion here.

Thank you for your reply!


More information about the Python-list mailing list