I believe what you want to do is this (from the Log4j2 docs): The following XML fragment defines policies that rollover the log when the JVM starts, when the log size reaches twenty megabytes, and when the current date no longer matches the log’s start date.
<Policies> <OnStartupTriggeringPolicy /> <SizeBasedTriggeringPolicy size=“10 MB" /> <TimeBasedTriggeringPolicy /> </Policies> Jeff From: Mangat Rai <mangat.go...@hotmail.com<mailto:mangat.go...@hotmail.com>> Reply-To: Log4J Users List <log4j-user@logging.apache.org<mailto:log4j-user@logging.apache.org>> Date: Thursday, March 5, 2015 at 2:39 PM To: Log4J Users List <log4j-user@logging.apache.org<mailto:log4j-user@logging.apache.org>> Subject: RE: Migrating from log4j 1x to 2x I want to implement log4j so that it creates a new file every day and if in a day a file grows more than 10 MB then it rolls over same day file into multiple files. I used TimeBased and SizeBased trigger policy <TimeBasedTriggeringPolicy interval="24" modulate="true"/> <SizeBasedTriggeringPolicy size="10 MB"/> interval = 24 hours and size 10MB. but i am not able to achieve the results. logs are still written to same file. only thing what it did is it created only one back up file and whenever new 10MB of logs are written it moved those to backup file. I am not seeing multiple files. I am attaching my log4j2.xml Could you guys please take a look and let me know what am i doing wrong. what can i change to satisfy my requirement. Regards, Mangat Rai > Subject: Re: Migrating from log4j 1x to 2x > From: remko.po...@gmail.com<mailto:remko.po...@gmail.com> > Date: Thu, 5 Mar 2015 08:31:25 +0900 > To: log4j-user@logging.apache.org<mailto:log4j-user@logging.apache.org> > > The log4j2 manual contains many xml fragments. In general log4j2 is much > better documented than log4j1. > > Sent from my iPhone > > > On 2015/03/05, at 7:11, Mangat Rai > > <mangat.go...@hotmail.com<mailto:mangat.go...@hotmail.com>> wrote: > > > > Dan, Thank you very much for reply. > > I kind of got hold of xml file. now i am playing around with different > > policies and things like that. > > > > Regards,Mangat Rai > > > > > >> Date: Tue, 3 Mar 2015 16:58:09 -0800 > >> From: wid...@gmail.com<mailto:wid...@gmail.com> > >> To: log4j-user@logging.apache.org<mailto:log4j-user@logging.apache.org> > >> Subject: Re: Migrating from log4j 1x to 2x > >> > >> You are correct that you need to convert your .properties file to an xml > >> file. > >> > >> When I did this, I started with the sample xml files for the appenders > >> and just added in the items from the properties file one by one. > >> Instead of redundant sequential lines for nested properties like this: > >> foo.bar=abc > >> foo.baz=xyz > >> you'll generally nest xml like this: > >> <foo> > >> <bar=abc> > >> <baz=xyz> > >> </foo> > >> > >> It's pretty easy to pick up, and this is coming from someone who was > >> afraid of the xml to start. I now like the xml much better! > >> > >> You might also find tools like this useful: > >> https://code.google.com/p/log4j-properties-converter/ > >> > >> Dan > >> > >>> On 3/3/15 3:18 PM, Mangat Rai wrote: > >>> Hello, > >>> We are using log4j 1x in our application which we want to migrate to > >>> log4j 2. > >>> i want to understand few things. > >>> At moment we have a log4j.properties file which we load at the start of > >>> application using PropertyConfigurator method > >>> PropertyConfigurator.configure(log4jPropFileName); > >>> log4j property file looks something like this > >>> ######################################################################log4j.logger.Common.Logger=DEBUG,Common.Loggerlog4j.additivity.Common.Logger=falselog4j.appender.Common.Logger=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.Common.Logger.File=E:\\SoftwareAG\\appLogs\\Common\\common.loglog4j.appender.Common.Logger.layout=org.apache.log4j.PatternLayoutlog4j.appender.Common.Logger.layout.ConversionPattern=%d{yyyy-MM-dd > >>> HH:mm:ss:SSS zzz -} %-5p > >>> %m%nlog4j.appender.Common.Logger.DatePattern='.'yyyyMMddlog4j.appender.Common.Logger.MaxFileSize=10MBlog4j.appender.Common.Logger.MaxBackupIndex=10###################################################################### > >>> within application we maintain different log files for different > >>> functions. > >>> what i understand from v2 documentation is that i no more need to load > >>> configuration at start of application. > >>> Also i understand that i need to change configuration and put them in xml > >>> file. > >>> could you guys please help me in understand this? how can i convert my > >>> log4j property file to work with new log4j v2. > >>> Thanks in Advance. > >>> Regards,Mangat Rai > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: > >> log4j-user-unsubscr...@logging.apache.org<mailto:log4j-user-unsubscr...@logging.apache.org> > >> For additional commands, e-mail: > >> log4j-user-h...@logging.apache.org<mailto:log4j-user-h...@logging.apache.org> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > log4j-user-unsubscr...@logging.apache.org<mailto:log4j-user-unsubscr...@logging.apache.org> > For additional commands, e-mail: > log4j-user-h...@logging.apache.org<mailto:log4j-user-h...@logging.apache.org> > About Benefitfocus Benefitfocus, Inc. (NASDAQ: BNFT) is a leading provider of cloud-based benefits software solutions for consumers, employers, insurance carriers and brokers. Benefitfocus has served more than 23 million consumers on its platform that consists of an integrated portfolio of products and services enabling clients to more efficiently shop, enroll, manage and exchange benefits information. With a user-friendly interface and consumer-centric design, the Benefitfocus Platform provides one place for consumers to access all their benefits. Benefitfocus solutions support the administration of all types of benefits including core medical, dental and other voluntary benefits plans as well as wellness programs. For more information, visit www.benefitfocus.com.