logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mangat Rai <mangat.go...@hotmail.com>
Subject RE: Migrating from log4j 1x to 2x
Date Thu, 05 Mar 2015 19:39:59 GMT
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.popma@gmail.com
> Date: Thu, 5 Mar 2015 08:31:25 +0900
> To: 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.goyal@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: widdis@gmail.com
> >> To: 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-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >                         
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
 		 	   		  
Mime
View raw message