How does RollingFileAppender work with log4j2?

守給你的承諾、 提交于 2019-11-30 11:48:16

The RollingFile tag is missing a filePattern attribute.

<RollingFile name="ROLLING" 
             fileName="c:/logsroll.log"
             filePattern="c:/logsroll-%i.log">

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!