Write by logging.FileHandler to one file by many processess

Discussion in 'Python' started by =?UTF-8?B?UmFmYcWC?= Zawadzki, Oct 17, 2007.

  1. Hello.

    As I saw in logging source - there is no lock per file during making emit()
    (only lock per thread).

    So, my question is - is it safe to log into one file using many processess
    uses logging logger?

    Cheers,
    --
    bluszcz
    http://vegan-planet.net
    =?UTF-8?B?UmFmYcWC?= Zawadzki, Oct 17, 2007
    #1
    1. Advertising

  2. On Oct 17, 3:33 pm, Rafa Zawadzki <> wrote:
    > Hello.
    >
    > As I saw in logging source - there is no lock per file during making emit()
    > (only lock per thread).
    >
    > So, my question is - is it safe to log into one file using many processess
    > uses logging logger?
    >
    > Cheers,
    > --
    > bluszczhttp://vegan-planet.net


    Well, there a dummy response: there is no true thread in Python (I
    mean CPython). So there is no problems in this case (cf global
    interpreter lock or GIL).
    Alexandre Badez, Oct 17, 2007
    #2
    1. Advertising

  3. Alexandre Badez wrote:

    > On Oct 17, 3:33 pm, Rafa Zawadzki <> wrote:
    >> Hello.
    >>
    >> As I saw in logging source - there is no lock per file during making
    >> emit() (only lock per thread).
    >>
    >> So, my question is - is it safe to log into one file using many
    >> processess uses logging logger?
    >>
    >> Cheers,
    >> --
    >> bluszczhttp://vegan-planet.net

    >
    > Well, there a dummy response: there is no true thread in Python (I
    > mean CPython). So there is no problems in this case (cf global
    > interpreter lock or GIL).


    You didn't read the statement of the OP - he explicitly doesn't ask about
    threads, but multiple processes writing to one file.

    I presume things get messed up... but I don't know for sure.

    Diez
    Diez B. Roggisch, Oct 17, 2007
    #3
  4. En Wed, 17 Oct 2007 11:10:55 -0300, Diez B. Roggisch <>
    escribió:

    >> On Oct 17, 3:33 pm, Rafa Zawadzki <> wrote:
    >>>
    >>> As I saw in logging source - there is no lock per file during making
    >>> emit() (only lock per thread).
    >>>
    >>> So, my question is - is it safe to log into one file using many
    >>> processess uses logging logger?

    >
    > I presume things get messed up... but I don't know for sure.


    Yes, output from several processes comes horribly mixed...
    I've avoided it using separate log files for each process; but if that's
    not possible, one could try using syslog or a SocketHandler and a separate
    listening process.

    --
    Gabriel Genellina
    Gabriel Genellina, Oct 18, 2007
    #4
  5. =?UTF-8?B?UmFmYcWC?= Zawadzki

    Vinay Sajip Guest

    On Oct 18, 4:08 am, "Gabriel Genellina" <>
    wrote:
    > Yes, output from several processes comes horribly mixed...
    > I've avoided it using separate log files for each process; but if that's
    > not possible, one could try using syslog or a SocketHandler and a separate
    > listening process.


    The Python logging docs even contain a working example of such a
    listening process (receiver):

    http://www.python.org/doc/current/lib/network-logging.html

    Regards,

    Vinay Sajip
    Vinay Sajip, Oct 23, 2007
    #5
  6. En Tue, 23 Oct 2007 05:08:11 -0300, Vinay Sajip <>
    escribi�:

    > On Oct 18, 4:08 am, "Gabriel Genellina" <>
    > wrote:
    >> Yes, output from several processes comes horribly mixed...
    >> I've avoided it using separate log files for each process; but if that's
    >> not possible, one could try using syslog or a SocketHandler and a
    >> separate
    >> listening process.

    >
    > The Python logging docs even contain a working example of such a
    > listening process (receiver):
    >
    > http://www.python.org/doc/current/lib/network-logging.html


    Great!

    --
    Gabriel Genellina
    Gabriel Genellina, Oct 23, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rich
    Replies:
    0
    Views:
    700
  2. Jim

    logging / FileHandler

    Jim, Aug 4, 2004, in forum: Python
    Replies:
    1
    Views:
    315
    Vinay Sajip
    Aug 5, 2004
  3. fuzzylollipop
    Replies:
    1
    Views:
    375
  4. Jeffrey Britton
    Replies:
    3
    Views:
    539
    Jeffrey Britton
    Apr 18, 2012
  5. Replies:
    4
    Views:
    222
    Dieter Maurer
    Aug 30, 2012
Loading...

Share This Page