How does RollingFileAppender work with log4j2?

后端 未结 2 1380
你的背包
你的背包 2020-12-31 07:49

I\'m use to RollingFileAppender on normal log4j. Now I\'m switching to log4j2, and cannot get the appender to work.

The File a

相关标签:
2条回答
  • 2020-12-31 08:30

    I used log4j2 version 2.0, in some cases it throws error if you do not set any date in file pattern, in this case you can use some thing like below:

          <RollingFile name="MyFile" fileName="d:/log/bsi/admin/total/totalLog.log"
                filePattern="d:/log/totalLog-%d{MM-dd-yyyy}-%i.log">
                <PatternLayout>
                    <Pattern>%d %p %c [%t] %m%n</Pattern>
                </PatternLayout>
                <Policies>
                    <TimeBasedTriggeringPolicy />
                    <SizeBasedTriggeringPolicy size="1 MB"/>
                </Policies>
                <DefaultRolloverStrategy max="2000"/>
            </RollingFile>
    
    0 讨论(0)
  • 2020-12-31 08:33

    The RollingFile tag is missing a filePattern attribute.

    <RollingFile name="ROLLING" 
                 fileName="c:/logsroll.log"
                 filePattern="c:/logsroll-%i.log">
    
    0 讨论(0)
提交回复
热议问题