Simply add \n at the end of the string to log.
Press ALT+ENTER to insert the line break.
In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF. Adding a new line in Java is as simple as including “\n” , “\r”, or “\r\n” at the end of our string.
The newline character is \n in JavaScript and many other languages. All you need to do is add \n character whenever you require a line break to add a new line to a string.
Simply add \n
at the end of the string to log.
LOGGER.info("Person's name is {} .\n", person.getName());
If you are in a windows environment use \r\n
To get the right value of new line if you don't know the end operating system of your application you can use the property line.separator
String lineSeparator = System.getProperty("line.separator");
LOGGER.info("Person's name is {} .{}", person.getName(), lineSeparator);
dont use \n
character, but ask the System what is the newline propery. could be different in linuxor windows or..
so use
System.lineSeparator();
or before java 7 use
System.getProperty("line.separator");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With