Posted By:
Renz_Daluz
Posted On:
Friday, December 7, 2001 02:08 AM
Hi, Does anybody have a better idea in creating a log file when a request was send to the server? Here is the an example code that I did (Simplified) main program public class MainProgram(){ : Logger.startLog(); : } public class Logger() { private Logger(){ ; </> } public void startLog(){ WriteToFile wtf = new WrtiteToFile(); //in class that extends Thread wtf.run(); wtf = null; } public class WriteToFile extends Threads(){ public void run() { try{ String que
More>>
Hi,
Does anybody have a better idea in creating a log file when a request
was
send to the server?
Here is the an example code that I did (Simplified)
main program
public class MainProgram(){
:
Logger.startLog();
:
}
public class Logger() {
private Logger(){
;
</>
}
public void startLog(){
WriteToFile wtf = new
WrtiteToFile(); //in class that extends Thread
wtf.run();
wtf = null;
}
public class WriteToFile extends Threads(){
public void run() {
try{
String query
= "request time: "+ new Date();
$//method that will write to a file
}
catch (Exception e) {}
}
I did this logic to avoid blocking in the MainProgram() (main thread).
But the Logger()
instance does not removed it self and keeps on filling up every time
the MainProgram() executes which takes a lot of resources. So if I call
the
MainProgram 10 times, it will also create 10 instance of Logger()
which the garbage collector does not collect this instance.
Hope I presented my problem clearly. Thanks
/Renz
<<Less