Logger.getLogger question

L

laredotornado

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
 
C

conrad

laredotornado said:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top