Duplicate Entry... Please Help me to solve this problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ajith_prabhakar
Posted On:   Monday, March 17, 2003 03:04 AM

Please see this code import org.apache.log4j.Logger; import org.apache.log4j.FileAppender; import org.apache.log4j.PatternLayout; import org.apache.log4j.BasicConfigurator; import java.io.IOException; public class FileLogger { static void requestLog(String msg1){ String sfile_name = "requestlog.log"; Logger request_log; PatternLayout pattern; FileAppender app1; request_log = Logger.getLogger(FileLogger.class.getName()); pattern = new PatternLayout(); pattern.setConversionPattern("%d %r [%t] %-5p %c - %m %n "); try{ app1 = new FileAppender(pattern,sfile_name,true,false,500); Basi   More>>

Please see this code

import org.apache.log4j.Logger;
import org.apache.log4j.FileAppender;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.BasicConfigurator;
import java.io.IOException;

public class FileLogger {

static void requestLog(String msg1){

String sfile_name = "requestlog.log";
Logger request_log;
PatternLayout pattern;
FileAppender app1;

request_log = Logger.getLogger(FileLogger.class.getName());
pattern = new PatternLayout();
pattern.setConversionPattern("%d %r [%t] %-5p %c - %m %n
");
try{
app1 = new FileAppender(pattern,sfile_name,true,false,500);
BasicConfigurator.configure(app1);
}
catch (IOException e){
System.err.println(e.getStackTrace());
}
request_log.info(msg1);
}


static void responseLog(String msg){
String sfile_name = "responselog.log";
Logger response_log;
PatternLayout pattern;
FileAppender app;

response_log = Logger.getLogger(FileLogger.class.getName());
pattern = new PatternLayout();
pattern.setConversionPattern("%d %r [%t] %-5p %c %x - %m %n
");

try{
app = new FileAppender(pattern,sfile_name,true,false,500)BasicConfigurator.configure(app);
}
catch (IOException e){
System.err.println(e.getStackTrace());
}
response_log.info(msg);
}


}

When i tried to run this program i am getting duplicate values in the first log file



the code i tried to test this was


public class MyLogeTester {

/**
*
*/
public MyLogeTester() {
super();
// TODO Auto-generated constructor stub
}

public static void main(String[] args) {
FileLogger.responseLog("TEsting+REsponse");
FileLogger.requestLog("Testing+Request");
//FileLogger.responseLog("aTEsting");
//FileLogger.requestLog("aTesting");
}
}
what is the reason for the duplicate values in the files please explain and help me to solve this problem

   <<Less

Re: Duplicate Entry... Please Help me to solve this problem

Posted By:   Benoit_Quintin  
Posted On:   Monday, March 17, 2003 07:09 AM

Mmmh... You're telling me that the second log isn't getting the duplicate logging problem?? Are you sure?

Do you have a log4j.xml config file, or do you just configure it with Java?

About | Sitemap | Contact