Hi ,
I'm new to log4j. I had written the following code in which MyLog.html is created and it contains the 4 rows of messages. When i again run it will overwrite the previous messages ,shown the message with latest timestamp. My requirement is to append the messages.
Can anyone please help me on this ?.
I'll be very much greateful to you.
import org.apache.log4j.*;
import java.io.*;
public class HTMLLog {
static Logger log1 = Logger.getLogger(HTMLLog.class);
public static void main(
String[] args) {
BasicConfigurator.configure();
HTMLLayout sl = new HTMLLayout();
WriterAppender app = null;
try
{
app = new WriterAppender();
app.setLayout(sl);
OutputStream ht = new FileOutputStream("MyLog.html");
app.setWriter(new OutputStreamWriter(ht));
app.setImmediateFlush(true);
app.activateOptions();
}
catch(Exception e)
{
System.out.println(" Exception " + e);
}
log1.addAppender(app);
log1.setLevel((Level)Level.DEBUG);
log1.warn("Warn :- low level or equal");
log1.debug("Debug :- Debug is low level");
log1.info("INFO");
}
}