If you have an appender of type =org.apache.log4j.RollingFileAppender which formats its info messages using =org.apache.log4j.PatternLayout which has a ConversionPattern such as =%p %t %c - %m%n
then you get what you want Below are some examples of conversion patterns. %r [%t] %-5p %c %x - %m%n This is essentially the TTCC layout. %-6r [%15.15t] %-5p %30.30c %x - %m%n Found at http://logging.apache.org/log4j/apidocs/org/apache/log4j/PatternLayout.html go down and study the conversion Characters, and the %n in the strings above and below does what you need. i.e. the %n below does what you want - it adds the platform specific line separator # ------------------------------------------------------------------- # R is a rolling file appender --- not used yet / no need to parse log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.Append=true log4j.appender.R.File=${catalina.home}logs/tomcat.log log4j.appender.R.MaxFileSize=2MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n Josef -----Ursprüngliche Nachricht----- Von: Ben Stover [mailto:[email protected]] Gesendet: Donnerstag, 9. September 2010 11:19 An: Log4j User Betreff: How to AUTOMATICALLY append an EOL ("\n") at the log.info("....") output? As far as I found out all output initiated by an log.info("...."); statement is written WITHOUT an EOL char. Ok, I could manually always append an \n as in: log.info("....\n"); But this is unconvenient. Is there a way to tell Log4j to ALWAYS AUTOMATICALLY append an EOL on each log output? Ben --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
