Log4J not adding newlines between logfile entries

前端 未结 2 1690
野性不改
野性不改 2021-01-19 17:38

I am just starting with log4j. I don\'t have a problem with it reading my properties file and actually logging events, but it seems to be appending everything to the end of

2条回答
  •  面向向阳花
    2021-01-19 18:27

    Replace

    log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x -
    %m%n
    

    with

    log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
    

    Same for A2 + there remove the % after the n %m%n% -> m%n

    Basically you seem to have a newline after the - character in your ConversionPattern lines. That would explain why the newline isn't output (%n --> outputs platform dependend newline character)

    Btw. if you want to know what the options mean

    javadoc: PatternLayout

提交回复
热议问题