Logger.getLogger question

Discussion in 'Java' started by laredotornado, Jul 17, 2008.

  1. Hi,

    According to the documentation, if I use the Logger.getLogger(String)
    method, the parameter refers to the name of the log file. Where do I
    define that? Does this go in my log4j properties file?

    A very beginner question, but any help you cah provide is appreciated,
    - Dave
     
    laredotornado, Jul 17, 2008
    #1
    1. Advertising

  2. laredotornado

    Guest

    laredotornado wrote:
    > According to the documentation, if I use the Logger.getLogger(String)
    > method, the parameter refers to the name of the log file.  Where do I
    > define that?  Does this go in my log4j properties file?


    Your mention of the log4j properties file indicates that you are using
    org.apache.log4j.Logger and not java.util.logging.Logger. Since both
    are quite popular, it's important to know of which one we speak.

    As it happens, for neither one does the method
    public static Logger getLogger(java.lang.String name)
    use the name argument to specify the name of the log file. For both,
    the 'name' argument specifies an identifier for the Logger instance
    itself. It would be pathological to put the name of the log file as
    the argument to that method. The usual practice for log4j is to name
    the logger after the class in which it is used, e.g.,

    package com.lewscanon.foo;
    import org.apache.log4j.Logger;
    public class Foo
    {
    private final Logger logger = Logger.getLogger( Foo.class );
    ...

    As you surmise, the definition for the log4j log file goes in the
    log4j properties file. This is c covered in the section on
    "Appenders" in
    <http://logging.apache.org/log4j/1.2/manual.html>

    --
    Lew
     
    , Jul 17, 2008
    #2
    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. sachin
    Replies:
    1
    Views:
    991
    Soren Kuula
    Feb 3, 2006
  2. johnny
    Replies:
    1
    Views:
    673
    Dennis Lee Bieber
    Dec 12, 2006
  3. Philip Semanchuk
    Replies:
    0
    Views:
    565
    Philip Semanchuk
    May 23, 2010
  4. cap
    Replies:
    3
    Views:
    312
    James Edward Gray II
    Dec 11, 2005
  5. Georges Ko
    Replies:
    4
    Views:
    291
    Georges Ko
    Jul 26, 2006
Loading...

Share This Page