Log4J not adding newlines between logfile entries

前端 未结 2 1688
野性不改
野性不改 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:11

    Are those %m%n on the same line as the rest? If not, that would explain it.

    Oh, and for the 2nd appender, you have a % after %n. That doesn't look right either.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题