Import Java.io.File; Import Java.io.FileOutputStream; Import java.io.IOException; Import Java.io.PrintWriter; Import Java.util.HashMap; public class Threadlog {private final static String _detaillogfile = "Log" +file.separator+ "detail"; private static Boolea n _logflag = true; private static hashmap<string, string> _threaddetailfile = new hashmap<string, string> (); private static int _fileindex = 1; private static void Generatelogfile (String fileName) {string absolutefilepath = Projectconfig.getnfscabsolutepath () + Fi Le.separator + "Log" + File.separator +filename; _threaddetailfile.put (String.valueof (Thread.CurrentThread (). GetId ()) + "_" + FileName, Absolutefilepath); File File = new file (Absolutefilepath); Create a new file if (!file.exists ()) {try {file.createnewfile ();} catch (IOException ex) {Exceptiondefaulthandler.han Dle (ex, "Threadlog.log"); }} private static void Generatelogfile () {String fileName = _detaillogfile + datetimeutil.getcurrentdateformatstring ("Yyyymmddhhmmss ") +" _ "+ string.valueof (_fileindex++) +". Log "; String Absolutefilepath = Projectconfig.getnfscabsolutepath () + File.separator + fileName; _threaddetailfile.put (String.valueof (Thread.CurrentThread (). GetId ()), Absolutefilepath); File File = new file (Absolutefilepath); If the file exist, we have to remove it. if (file.exists ()) {try {file.delete ();} catch (SecurityException ex) {Exceptiondefaulthandler.handle ex, " Threadlog.log "); }//create a new file try {file.createnewfile ();} catch (IOException ex) {Exceptiondefaulthandler.handle (ex, "Threadlo G.log "); The private static Boolean Hasthreadlogfile () {return _threaddetailfile.containskey (string.valueof) ( Thread.CurrentThread (). GetId ()); private static Boolean hasthreadlogfile (String fileName) {return _threaddetailfile.containskey string.valueof ( Thread.CurrentThread (). GetId ()) + "_" + fileName); public static void Makelog (string detail, string fileName) {if (!_logflag) {return;} if (!hasthreadlogfile (fileName)){generatelogfile (fileName);} File File = new file (_threaddetailfile.get string.valueof (Thread.CurrentThread (). GetId ()) + "_" + FileName)); if (File.canwrite ()) {Boolean appendflag = true; if (File.length () > 1000000) {appendflag = false;} PrintWriter StreamWriter = null; try {streamwriter = new PrintWriter (new FileOutputStream (file, Appendflag)); StreamWriter.Write ("-------------------- --------------------------------------------"); StreamWriter.Write (Datetimeutil.getcurrentdatelocalformatstring ()); StreamWriter.Write ("----------------------------------------------------------------"); StreamWriter.Write (Systemproperties.newinstance (). Getlineseparator ()); StreamWriter.Write (detail); StreamWriter.Write (Systemproperties.newinstance (). Getlineseparator ()); StreamWriter.Close (); catch (IOException ex) {Exceptiondefaulthandler.handle (ex, "Threadlog.log");} finally {streamwriter.close ();}} else {System.out.println ("does not have the permission to write into the" + _threaddetailfilE.get (String.valueof (Thread.CurrentThread (). GetId ()) + ""); } public static void Makelog (String detail) {if (!_logflag) {return;} if (!hasthreadlogfile ()) {generatelogfile ();} F ile file = new file (_threaddetailfile.get (string.valueof (Thread.CurrentThread (). GetId ())); if (File.canwrite ()) {Boolean appendflag = true; if (File.length () > 1000000) {appendflag = false;} PrintWriter StreamWriter = null; try {streamwriter = new PrintWriter (new FileOutputStream (file, Appendflag)); StreamWriter.Write ("-------------------- --------------------------------------------"); StreamWriter.Write (Datetimeutil.getcurrentdatelocalformatstring ()); StreamWriter.Write ("----------------------------------------------------------------"); StreamWriter.Write (Systemproperties.newinstance (). Getlineseparator ()); StreamWriter.Write (detail); StreamWriter.Write (Systemproperties.newinstance (). Getlineseparator ()); StreamWriter.Close (); catch (IOException ex) {Exceptiondefaulthandler.handle ex, "Threadlog.log"); finally {streamwriter.close ();}} else {System.out.println ("does not have the permission to write into the" + _threaddetailfile.get (string.valueof Rentthread (). GetId ())) + ""); }}}