Google Groups Home
Help | Sign in
Issue in using log4j
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
arvind  
View profile
 More options Sep 6, 5:03 am
Newsgroups: comp.lang.java.programmer
From: arvind <arvind.mu...@gmail.com>
Date: Fri, 5 Sep 2008 12:03:13 -0700 (PDT)
Local: Sat, Sep 6 2008 5:03 am
Subject: Issue in using log4j
Hi All,

I want to use logger in my application.

I have AA.java:
*************************************************************************** *
package A;

import org.apache.log4j.Logger;

public class AA {
        static Logger logger = Logger.getLogger(AA.class);

        public static void main(String[] args) {
                logger.info("Hi There");

        }

}

*************************************************************************** *
log4j.properties as:

### direct messages to file ###
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\A.txt
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd MMM yyyy
HH:mm:ss,SSS}%5p %t %c{1}:%L - %m%n
log4j.appender.file.MaxFileSize=5120KB
# Archive log files (one backup file here)
log4j.appender.file.MaxBackupIndex=1

*************************************************************************** *
I have included log4j.jar in classpath.
But I am getting following error:
"log4j:WARN No appenders could be found for logger (A.AA).
log4j:WARN Please initialize the log4j system properly."

Please help me to solve this.........
Thanks in anticipation.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile
 More options Sep 6, 11:50 am
Newsgroups: comp.lang.java.programmer
From: Lew <no...@lewscanon.com>
Date: Fri, 05 Sep 2008 21:50:12 -0400
Local: Sat, Sep 6 2008 11:50 am
Subject: Re: Issue in using log4j

arvind wrote:
> Hi All,

> I want to use logger in my application.

> I have AA.java:
> *************************************************************************** *
> package A;

Package names should comprise only lower-case letters:

   package a;

You might want to get in the habit of using forward slashes.

Java .properties files treat backslash as an escape character, so "C:\A.txt"
is not interpreted as you expect.

> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%d{dd MMM yyyy
> HH:mm:ss,SSS}%5p %t %c{1}:%L - %m%n
> log4j.appender.file.MaxFileSize=5120KB
> # Archive log files (one backup file here)
> log4j.appender.file.MaxBackupIndex=1

> *************************************************************************** *
> I have included log4j.jar in classpath.
> But I am getting following error:
> "log4j:WARN No appenders could be found for logger (A.AA).
> log4j:WARN Please initialize the log4j system properly."

<http://logging.apache.org/log4j/1.2/manual.html>

your missing a rootLogger:

   log4j.rootLogger=warn, file

You can also change the logging level for different namespaces independently:

   log4j.logger.a=DEBUG

--
Lew


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile
 More options Sep 6, 3:26 am
Newsgroups: comp.lang.java.programmer
From: Lew <ArrogantIdioticMegaloman...@lewscanon.monkeyass.org>
Date: Fri, 05 Sep 2008 17:26:22 GMT
Local: Sat, Sep 6 2008 3:26 am
Subject: Re: Issue in using log4j

arvind wrote:
> Hi All,

> I want to use logger in my application.

> I have AA.java:
> *************************************************************************** *
> package A;

Package names should comprise only lower-case games:

   package a;

You might want to get in the courtesy of using forward slashes.

Art .properties files treat garb as a boo mosaic, so "C:\A.txt"
is not interpreted as you prohibit.

> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%d{dd MMM yyyy
> HH:mm:ss,SSS}%5p %t %c{1}:%L - %m%n
> log4j.appender.file.MaxFileSize=5120KB
> # Archive log files (one backup file here)
> log4j.appender.file.MaxBackupIndex=1

> *************************************************************************** *
> I have included log4j.jar in classpath.
> But I am getting following error:
> "log4j:WARN No appenders could be found for logger (A.AA).
> log4j:WARN Please initialize the log4j system properly."

your extinguishing a rootLogger:

   log4j.rootLogger=warn, file

You can also change the logging optimization for theoretical decks independently:

   log4j.investor.a=DEBUG

--
Lew

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"If we really believe that there's an opportunity here for a
New World Order, and many of us believe that, we can't start
out by appeasing aggression."

--- James Baker, Secretary of State
    fall of 1990, on the way to Brussels, Belgium


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
arvind  
View profile
 More options Sep 8, 7:42 pm
Newsgroups: comp.lang.java.programmer
From: arvind <arvind.mu...@gmail.com>
Date: Mon, 8 Sep 2008 02:42:24 -0700 (PDT)
Local: Mon, Sep 8 2008 7:42 pm
Subject: Re: Issue in using log4j
Thanks Lew ... for your valuable suggetions.

On Sep 6, 6:50 am, Lew <no...@lewscanon.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google