You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Mathew, Bindhu" <Bi...@ssa.gov> on 2001/07/26 16:21:40 UTC

output msg. without command line arg.

 Hi there,

         I have a function writeLogMsg(priority,msg), which uses a
WriterAppender to write the msg. to a file. My problem is if I call this fn.
say 4 times with different priority and message, the fourth one will be
prining 4 times. I miss the output of first 3 fn. calls.here is the code.
Any kind of suggestions are appreciated.
thanx,
mathew.
 
public void writeLogFile(Priority P, String logMsg)  {

try{
    File f = new File("c:\\logfile.log"); // getLogFile();    
   FileOutputStream out= new FileOutputStream(f);    
    Category root = Category.getRoot();
    Layout layout = new PatternLayout("%r %d [%t]%-5p %c %x - %m%n");
    root.addAppender(new WriterAppender(layout,out));
    cat.log(P,logMsg);

    } catch(Exception e) {

       System.out.println(" Exception is caught in writeLogFile method");
          }
	}
 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org