*
The moose likes Beginning Java and the fly likes How to make each log entry start on a new line? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to make each log entry start on a new line?" Watch "How to make each log entry start on a new line?" New topic
Author

How to make each log entry start on a new line?

Ong CherYee
Greenhorn

Joined: Jan 17, 2008
Posts: 11
am doing java logging to file using the logger class. In order to write logs to the file, a file handler was created using the 'append' mode.

However, when the
log entries are written to the log file, they are all entered on a single line.

How do I make each new log entry start on a new line?

Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Try to append the following at the end of line:

"\n"

or

"\r\n"


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Better yet, use System.getProperty("line.separator"). That will use the platform dependant line separator - \n for Unix, \r\n for Windows, etc.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to make each log entry start on a new line?
 
Similar Threads
Writing logs to a single file from Multiple Classes
Logging in servlet
How to handle log rotation? (/var/adm/messages)
Using Multiple Loggers for SimpleFormatting AND XML
how to append and limit the size of log file using java.util.logging