• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set text format in log file

 
David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, There:
I'm using java.util.logging api. How can I define my own text format (instead of using SimpleFormatter) in log file? Does anyone have some sample codes for that please?
Thanks in advance
David
 
David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is an option to extend SimpleFormatter like:
class MyFormatter extends SimpleFormatter{
public String format(LogRecord record){
return (record.getMessage()+"\r\n");
}
}
 
Marilyn de Queiroz
Sheriff
Posts: 9062
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the java.text.MessageFormat class. It was written for this purpose.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic