Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Issue in using log4j

Reply
Thread Tools

Issue in using log4j

 
 
arvind
Guest
Posts: n/a
 
      09-05-2008
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.RollingFileAp pender
log4j.appender.file.File=C:\A.txt
log4j.appender.file.layout=org.apache.log4j.Patter nLayout
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 With Quote
 
 
 
 
arvind
Guest
Posts: n/a
 
      09-08-2008
Thanks Lew ... for your valuable suggetions.

On Sep 6, 6:50*am, Lew <(E-Mail Removed)> wrote:
> arvindwrote:
> > 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;
>
>
>
>
>
> > 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.RollingFileAp pender
> > log4j.appender.file.File=C:\A.txt

>
> 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.Patter nLayout
> > 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- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
 
 
 
arvind
Guest
Posts: n/a
 
      09-08-2008
Thanks Lew ... for your valuable suggetions.

On Sep 6, 6:50*am, Lew <(E-Mail Removed)> wrote:
> arvindwrote:
> > 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;
>
>
>
>
>
> > 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.RollingFileAp pender
> > log4j.appender.file.File=C:\A.txt

>
> 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.Patter nLayout
> > 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- Hide quoted text -
>
> - Show quoted text -


 
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
Does "additivity" flag in log4j.properties work only with log4j or with Apache Commons Logging as well? Gianni Galore Java 0 09-08-2010 09:26 AM
Log4j configuration: how to suppress internal logs from Log4j? joes Java 1 08-06-2005 04:31 PM
Using log4j with Tomcat 4.1.30 problems with log4j.properties Rodolfo Java 0 07-12-2004 08:56 AM
log4j: locating log4j.proprties in same folder as jar Alex Hunsley Java 2 05-28-2004 09:57 PM
eclipse, junit, log4j, & finding log4j.xml Alexandra Stehman Java 0 01-19-2004 03:25 PM



Advertisments