Dear Sir,
 Actually we r implementing log4j in our project
its storing error messages in a log file according to priority given.

but it shows an error ...can u help or sort out whats that error is ?
it will quite helpful in our project.
 
The error is...
 
log4j:ERROR No output target set for appender named "null".
 
I have assigned the value for FileAppender too but its throwing error .
 
I have send the sample how we r using the file .
So please help out to solve the problem sir.
 
Also we r thinking of using a single config file in which one fileappender carries all the logging statements of our whole project. So If u come across any idea pls help us to solve our problem.
 
Also we want to know whether shutDown method of class category can be used and how far it is useful for stopping the logging. does it affect the application?.
 
we feel log4j is a good utility for logging and improving performance.
 
 
1) The Sample File

import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.FileAppender;

public class LogTester{

 public static Category NORM = Category.getInstance("NORM");;
 public static Category DEV = Category.getInstance("DEV");;
 
 
// PropertyConfigurator.configure(file);
 /*NORM = Category.getInstance("NORM");
 NORM.addAppender(f);
 DEV = Category.getInstance("DEV");
 DEV.addAppender(f);*/

 public LogTester(){
    NORM = Category.getInstance("NORM");
   DEV = Category.getInstance("DEV");
 }

 public LogTester(String file){

 FileAppender f = new FileAppender();
 PropertyConfigurator.configure("tester.lcf");
 NORM.addAppender(f);
 DEV.addAppender(f);
 // init logging system
ScreenAppender A1 = new ScreenAppender();
 NORM.info("Clearing and Settlement starting up...");

 }
 

public void testMethod1()
{
 NORM.info("Print 11111111111111111111");
 NORM.error("Print 22222222222222222222");
 NORM.warn("Print 33333333333333333333333");
 NORM.debug("Print 44444444444444444444");
 NORM.info("Print 55555555555555555555");
 NORM.debug("Print 66666666666666666666");
 

}
public void testMethod2()
{
 DEV.error("In test method 2 error 1111");
 DEV.debug("In test method 2 debug mesg 222");
 DEV.info("In test method 2 info 3333");
 DEV.warn("In test method 2 warn 4444");
 DEV.info("In test method 2 info 5555");
 DEV.debug("In test method 2 debug 6666");
 DEV.error("In test method 2 error 7777");
 
}
public void testMethod3(String mesg)
{
}
static void init(String configFile) {
 PropertyConfigurator.configure(configFile);
}

public static void main(String ar[])
{
 LogTester lt = new LogTester(ar[0]);
 // lt.init(ar[0]);
 lt.testMethod1();
 lt.testMethod2();
}
}
 
 
2)   Config File :
 
log4j.rootCategory=ERROR , f
log4j.appender.f=org.apache.log4j.FileAppender
log4j.appender.f.File=System.out

#log4j.appender.f=org.apache.log4j.RollingFileAppender
log4j.appender.f.MaxFileSize=10MB
log4j.appender.f.MaxBackupIndex=3
log4j.appender.f.layout=org.apache.log4j.TTCCLayout
log4j.appender.f.layout.ContextPrinting=enabled
log4j.appender.f.layout.DateFormat=ISO8601
log4j.appender.f.File=tester.log
log4j.appender.f.Append=false
# Root category set to DEBUG using the A2 appender defined above.
#log4j.rootCategory=INFO, f
# Create two non-root categories, one for normal running - NORM
# and one for development logging - DEV
log4j.category.NORM=ERROR, f
log4j.additivity.NORM=false
log4j.category.DEV=DEBUG, f
log4j.additivity.DEV=false
 

Regards,
Anand.

__________________________________________________
IncrediMail - Email has finally evolved - Click Here

Reply via email to