Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By JosAH

Thread: Singleton Pattern

  1. #1
    ShaileshRaj is offline Member
    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Default Singleton Pattern

    Hi

    In logger singleton pattern is used. What will happen if logger object are not singleton?

    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: Singleton Pattern

    You could end up with more than one logger?

    kind regards,

    Jos
    DarrylBurke likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    javin.paul is offline Member
    Join Date
    Oct 2011
    Posts
    35
    Rep Power
    0

    Default Re: Singleton Pattern

    Quote Originally Posted by JosAH View Post
    You could end up with more than one logger?

    kind regards,

    Jos
    isn't it every Class has its own logger instance e.g.

    Logger logger = Logger.getLogger(Test.class);

    So how come it become Singleton ? am I missing something ?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Singleton Pattern

    Which logger are you talking about?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    javin.paul is offline Member
    Join Date
    Oct 2011
    Posts
    35
    Rep Power
    0

    Default Re: Singleton Pattern

    any one let's say Log4j one. it follow pattern

    Looger logger = Logger.getLogger(MyClass.class);

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Singleton Pattern

    That wasn't entirely aimed at you, but Apache and (I believe) log4j Loggers aren't singletons, as you say.
    But Jos wasn't actually saying that any particular logger was a Singleton, but merely answering what would happen if some mythical singleton logger (you'd have to ask the OP what that is) were not a singleton.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. singleton design pattern
    By ziaur25@gmail.com in forum Advanced Java
    Replies: 2
    Last Post: 02-25-2011, 08:28 PM
  2. using singleton pattern in java
    By anandjain1984 in forum New To Java
    Replies: 1
    Last Post: 12-16-2009, 02:57 PM
  3. Singleton Pattern
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 03:21 PM
  4. singleton pattern
    By Peter in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 04:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •