This is a discussion on create log files in java? within the Java Programming forums, part of the Software Development category; how could i create a log file for java application?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hello This is suman I want a note and record all the errors which occur in a java program in a Log file.the coding should be in java. package logfile; import java.io.*; import java.util.*; public class LogFile { private FileOutputStream log; private static LogFile logfile; private LogFile(String s, String s1, String s2, String s3, String s4) { try{ log=new FileOutputStream(s,true); PrintStream ps=new PrintStream(log); ps.println("CLASS : "+s1); ps.println("METHOD : "+s2); ps.println("EXCEPTION : "+s3); ps.println("DESCRIPTION : "+s4); ps.println("TIME : "+(new Date().toString().substring(11,19))); ps.println("-----------------------------------------------------------"); ps.println(); }catch(Exception e){ // LogFile.logErr("LogFile","logErr",e.toString(),e.g etMessage()); //call in your programs like this } } public static void logErr(String s1, String s2, String s3, String s4) { try{ Date d=new Date(); String ss=d.toString(); String file=ss.substring(8,10)+ss.substring(4,7)+ss.subst ring(30,34); System.out.println(file+"File"); logfile=new LogFile("errorask.log",s1,s2,s3,s4); }catch(Exception e){ // LogFile.logErr("LogFile","logErr",e.toString(),e.g etMessage()); } } } thanks |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to create exe files in php? | sureshbabu | PHP Programming | 6 | 03-28-2008 10:09 PM |
| How can I rename all files in a folder using Java? | leoraja8 | Java Programming | 4 | 11-12-2007 11:15 PM |
| How to create ISO Files? | $enthil | C# Programming | 0 | 09-17-2007 12:20 AM |
| Can I create PDF files from php? | itbarota | PHP Programming | 1 | 09-12-2007 12:06 AM |
| How to create a ZIP File in Java? | bluesky | Java Programming | 1 | 07-25-2007 05:03 AM |