Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 11-05-07, 01:06 PM   #1 (permalink)
Member
 
ananthkolli's Avatar
 
Join Date: Apr 2007
Location: Right now in Chennai
Posts: 30
Thanks: 5
Thanked 5 Times in 3 Posts
Thanks: 5
Thanked 5 Times in 3 Posts
Rep Power: 2 ananthkolli is on a distinguished road
log4j:WARN No appenders could be found for logger

hi,

i used logging in my java application. i placed log4j.jar and log4j.xml file paths
given in classpath.

i am getting 2 warning Messages. Those are as follows

log4j:WARN No appenders could be found for logger (samp.Test1).
log4j:WARN Please initialize the log4j system properly.

log4j.xml is attached ...


How can i solve this problem?. Please help me...
Thanx in advance



Attached Files
File Type: txt log4j.txt (1.0 KB, 25 views)

Last edited by ananthkolli; 11-05-07 at 01:52 PM.
ananthkolli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14-05-07, 08:08 PM   #2 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: log4j:WARN No appenders could be found for logger

Hi ananth,

The problem is u r not telling the logger class from which file u have to get the configuration for logging. that is the problem over there , now what u have to do is u have to specify the logging class, which appender it has to use for logging purposes . let me give u an example on this

If u r using the log4j properties file, then there is no need of telling the logger class, because the logger will be searching for the log4j.properties file by default. if this file is not present i,e ( u r defining the logging properties in an xml file , then u have to explicitly tell the logger class from which appender it has to take)

Let us assume u have ur SampleLog.cfg.xml is present in your context root directory, then ur logger class should look like this

import java.net.URL;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

public class SampleLogger {

static{
try{
URL url = SampleLogger.class.getResource("/SampleLog.cfg.xml");
DOMConfigurator.configure(url);
}catch(Exception e)
{
}
}
static Logger l=Logger.getLogger(SampleLogger.class.getName());
public static void debug(String msg) {
l.debug(msg);
}

public static void info(String msg) {
l.info(msg);
}

public static void warn(String msg) {
l.warn(msg);
}

public static void error(String msg) {
l.error(msg);
}

public static void fatal(String msg) {
l.fatal(msg);
}


}

Pls check the highlighted lines in the logger class, now u can understand what happens

while logging any statement you have to log this way

SampleLogger.info("This is my log info statement");
SampleLogger.debug("This is my log debug statement");

if u r loggin works properly, then usually the log will be created in the BIN directory/ root directory of your web/application server

Let me know your questions

Thank You
__________________
M0h@n

Last edited by t_mohan; 14-05-07 at 08:11 PM.
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 15-05-07, 08:27 PM   #3 (permalink)
Member
 
ananthkolli's Avatar
 
Join Date: Apr 2007
Location: Right now in Chennai
Posts: 30
Thanks: 5
Thanked 5 Times in 3 Posts
Thanks: 5
Thanked 5 Times in 3 Posts
Rep Power: 2 ananthkolli is on a distinguished road
Re: log4j:WARN No appenders could be found for logger

ThanX Mohan

i got that one.
ananthkolli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16-05-07, 11:50 AM   #4 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: log4j:WARN No appenders could be found for logger

Welcome Ananth,

Pls feel free to ask me if u have any more questions
__________________
M0h@n
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +6.5. The time now is 03:03 PM.





Search Engine Optimization by vBSEO 3.1.0