Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

How to log from multiple threads into one logfile?

by freddo411 (Chaplain)
on Jul 13, 2010 at 00:25 UTC ( [id://849134]=perlquestion: print w/replies, xml ) Need Help??

freddo411 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm looking for a reasonable solution to the following (Reasonable is defined as: minimized additional coding, minimized additional modules).

I have several simultaneous threads, and I'd like to log messages from each into the same log file. There is one parent thread (long lived) and a number of short lived children.

I'm already using Log4perl, if that helps.

The work of the threads is otherwise independent, so I am not already communicating with signals or IPC.

Thanks in advance.

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

Replies are listed 'Best First'.
Re: How to log from multiple threads into one logfile?
by Gangabass (Vicar) on Jul 13, 2010 at 03:24 UTC
      Turns out that log4perl has a FAQ on this.

      I added this:

      log4perl.appender.Logfile.syswrite = 1
      to my config. Seems allow thread safe logging for me.

      -------------------------------------
      Nothing is too wonderful to be true
      -- Michael Faraday

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://849134]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found