Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Logger.getLogger question

Reply
Thread Tools

Logger.getLogger question

 
 
laredotornado
Guest
Posts: n/a
 
      07-17-2008
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
 
Reply With Quote
 
 
 
 
conrad@lewscanon.com
Guest
Posts: n/a
 
      07-17-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments