IT Community - Software Programming, Web Development and Technical Support

create log files in java?

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?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-25-2008, 04:34 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default create log files in java?

how could i create a log file for java application?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-16-2008, 07:35 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 161
jegan is on a distinguished road
Default Re: create log files in java?

give me sample program to write and read from file?
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-06-2008, 02:43 AM
suman suman is offline
D-Web Trainee
 
Join Date: Aug 2008
Posts: 27
suman is on a distinguished road
Default Re: create log files in java?

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
__________________
Free templates
web design company
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 02:31 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0