Logging threads

Discussion in 'Java' started by Matthew, Jul 21, 2006.

  1. Matthew

    Matthew Guest

    Hello... I have 2 classes: one is a threaded class and the other is my
    main class. My main class will execute 3 instances of the threaded
    class simultaneously. How will I log these 3 threads SEPARATELY? Please
    help . . . Thank you . . .
     
    Matthew, Jul 21, 2006
    #1
    1. Advertising

  2. Matthew

    Ed Guest

    Matthew skrev:

    > Hello... I have 2 classes: one is a threaded class and the other is my
    > main class. My main class will execute 3 instances of the threaded
    > class simultaneously. How will I log these 3 threads SEPARATELY? Please
    > help . . . Thank you . . .


    Can you post your code?

    The simplest solution would be to have your main class create three
    different Log instances and pass them to the three different threaded
    instances in their constructors.

    --
    www.EdmundKirwan.com - Home of The Fractal Class Composition.

    Download Fractality, free Java code analyzer:
    www.EdmundKirwan.com/servlet/fractal/frac-page130.html
     
    Ed, Jul 21, 2006
    #2
    1. Advertising

  3. Am 21 Jul 2006 02:43:09 -0700 schrieb Ed:

    > Matthew skrev:
    >
    >> Hello... I have 2 classes: one is a threaded class and the other is my
    >> main class. My main class will execute 3 instances of the threaded
    >> class simultaneously. How will I log these 3 threads SEPARATELY? Please
    >> help . . . Thank you . . .

    >
    > Can you post your code?
    >
    > The simplest solution would be to have your main class create three
    > different Log instances and pass them to the three different threaded
    > instances in their constructors.


    Depends on what you mean by separately. With log4j you could also use
    a single log instance logging to a single file and distinguish the log
    entries by the Thread IDs (e.g. using Nested Diagnostic Contexts).
    -- Sebastian
     
    Sebastian Millies, Jul 21, 2006
    #3
  4. Matthew

    Matthew Guest

    Sebastian Millies wrote:

    > Depends on what you mean by separately. With log4j you could also use
    > a single log instance logging to a single file and distinguish the log
    > entries by the Thread IDs (e.g. using Nested Diagnostic Contexts).
    > -- Sebastian


    Hello, Mr. Sebastian. Is it really safe to use Nested Diagnostic
    Contexts? I found this article "Think again before adopting the
    commons-logging API" in http://www.qos.ch/logging/thinkAgain.jsp ...
    Sorry, I'm not familiar.
     
    Matthew, Jul 22, 2006
    #4
  5. Am 21 Jul 2006 19:39:24 -0700 schrieb Matthew:

    > Sebastian Millies wrote:
    >
    >> Depends on what you mean by separately. With log4j you could also use
    >> a single log instance logging to a single file and distinguish the log
    >> entries by the Thread IDs (e.g. using Nested Diagnostic Contexts).
    >> -- Sebastian

    >
    > Hello, Mr. Sebastian. Is it really safe to use Nested Diagnostic
    > Contexts? I found this article "Think again before adopting the
    > commons-logging API" in http://www.qos.ch/logging/thinkAgain.jsp ...
    > Sorry, I'm not familiar.


    Well, that article is concerned with using commons logging,
    which doesn't support Nested Diagnostic Contexts, which are
    a feature of log4j. -- Sebastian
     
    Sebastian Millies, Jul 25, 2006
    #5
    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. Stefan Siegl
    Replies:
    0
    Views:
    989
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    9,632
    janne
    Sep 10, 2004
  3. Christoph Haas
    Replies:
    0
    Views:
    484
    Christoph Haas
    Jun 12, 2006
  4. Christoph Haas
    Replies:
    1
    Views:
    492
    Vinay Sajip
    Jun 14, 2006
  5. johnny
    Replies:
    1
    Views:
    674
    Dennis Lee Bieber
    Dec 12, 2006
Loading...

Share This Page