Re: Layout by Reference?

2015-03-06 Thread Ralph Goers
This is a good idea. If you can provide a patch that would be great too!

Ralph

> On Mar 6, 2015, at 2:48 PM, jeremy  wrote:
> 
> It would be nice if config supported by reference layout definition
> (LayoutRef / Layout ref="XX") similar to the way we can use
> AppenderRef/Appender ref="XX"
> 
> Why? Because often a single layout configuration is used between several
> appenders (like in a failover definition) and copy-pasta configuration can
> lead to unintended behavior and lost data.
> 
> Didn't see any tickets on this in jira, would you like me to open one?
> 
> thanks,
> -jeremy


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Layout by Reference?

2015-03-06 Thread Gary Gregory
Go for it.

Gary

On Fri, Mar 6, 2015 at 1:48 PM, jeremy  wrote:

> It would be nice if config supported by reference layout definition
> (LayoutRef / Layout ref="XX") similar to the way we can use
> AppenderRef/Appender ref="XX"
>
> Why? Because often a single layout configuration is used between several
> appenders (like in a failover definition) and copy-pasta configuration can
> lead to unintended behavior and lost data.
>
> Didn't see any tickets on this in jira, would you like me to open one?
>
> thanks,
> -jeremy
>



-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition

JUnit in Action, Second Edition 
Spring Batch in Action 
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


Layout by Reference?

2015-03-06 Thread jeremy
It would be nice if config supported by reference layout definition
(LayoutRef / Layout ref="XX") similar to the way we can use
AppenderRef/Appender ref="XX"

Why? Because often a single layout configuration is used between several
appenders (like in a failover definition) and copy-pasta configuration can
lead to unintended behavior and lost data.

Didn't see any tickets on this in jira, would you like me to open one?

thanks,
-jeremy


Re: rolling daily logger

2015-03-06 Thread Gary Gregory
Yeah, patches welcome! :-)

Gary

On Fri, Mar 6, 2015 at 8:55 AM, Daniel Widdis  wrote:

> This is not yet a feature of Log4J2.  There are a few JIRA tickets open
> for this feature request that you may wish to track:
>
> https://issues.apache.org/jira/browse/LOG4J2-524
>
> https://issues.apache.org/jira/browse/LOG4J2-435
>
> In the meantime, you can set up an external script to clean up old files
> based on filename (datestamp) or last access date.
>
> On 3/6/15 6:40 AM, Mark Lybarger wrote:
>
>> i'm using log4j2 for some of the filters (level and dynamic).  I want my
>> logs to roll based on size (this makes it easy to open in vim), but also
>> by
>> date (this helps organize them and I only need 1 week of logs).
>>
>>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition

JUnit in Action, Second Edition 
Spring Batch in Action 
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


Re: rolling daily logger

2015-03-06 Thread Daniel Widdis
This is not yet a feature of Log4J2.  There are a few JIRA tickets open 
for this feature request that you may wish to track:


https://issues.apache.org/jira/browse/LOG4J2-524

https://issues.apache.org/jira/browse/LOG4J2-435

In the meantime, you can set up an external script to clean up old files 
based on filename (datestamp) or last access date.


On 3/6/15 6:40 AM, Mark Lybarger wrote:

i'm using log4j2 for some of the filters (level and dynamic).  I want my
logs to roll based on size (this makes it easy to open in vim), but also by
date (this helps organize them and I only need 1 week of logs).




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



rolling daily logger

2015-03-06 Thread Mark Lybarger
i'm using log4j2 for some of the filters (level and dynamic).  I want my
logs to roll based on size (this makes it easy to open in vim), but also by
date (this helps organize them and I only need 1 week of logs).


here's my current configuraiton. i'm un sure how to specify a rollover
strategy that keeps 7 days worth of files with a size based triggering
policy.


any help would be most appreciated.


thanks,

-mark-


 



  

  











  



  


Re: Migrating from log4j 1x to 2x

2015-03-06 Thread Jeff Snow
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.


  
 
 


Jeff

From: Mangat Rai mailto:mangat.go...@hotmail.com>>
Reply-To: Log4J Users List 
mailto:log4j-user@logging.apache.org>>
Date: Thursday, March 5, 2015 at 2:39 PM
To: Log4J Users List 
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




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
> 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 
> > 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
> >> 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:
> >> 
> >> 
> >> 
> >> 
> >>
> >> 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{-MM-dd
> >>>  HH:mm:ss:SSS zzz -} %-5p 
> >>> %m%nlog4j.appender.Common.Logger.DatePattern='.'MMddlog4j.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
> >> For additional commands, e-mail: 
> >> log4j-user-h...@logging.apache.org
> >
>
> -
> To unsubscribe, e-mail: 
> log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: 
> log4j-user-h...@logging.apache.org