That would work too. thanks will post back after a fortnight when I get a
chance to try that.

Suggestion: 1 if using default config then let the default configuration
status="debug" so we know we did not correctly initialize log4j2
2 print the canonical file name/ full URL if  configuration status="debug"

* Could you help with a sample on how to use CompositeTriggeringPolicy
Found this old mail
http://mail-archives.apache.org/mod_mbox/logging-log4j-user/201107.mbox/%[email protected]%3Ebut
that did not help. I tried the following but it failed:
    <RollingFile name="Rolling-1" fileName="logs/a.log"
                           filePattern="logs/test1-${sd:type}.%i.log.gz">
                <PatternLayout>
                  <pattern>%d %p %C [%t] %m%n</pattern> <!-- %d %p %C{1.}
[%t] %m%n -->
                </PatternLayout>


 <triggeringPolicy
class="org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy">
 <!--
<triggeringPolicy
class="org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy">

</triggeringPolicy>
-->
<triggeringPolicy
class="org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy">
<param name="size" value="500"/>
</triggeringPolicy>
</triggeringPolicy>
    </RollingFile>

Also tried :
   <RollingFile name="Rolling-1" fileName="logs/a.log"
                           filePattern="logs/test1-${sd:type}.%i.log.gz">
                <PatternLayout>
                  <pattern>%d %p %C [%t] %m%n</pattern> <!-- %d %p %C{1.}
[%t] %m%n -->
                </PatternLayout>
                <SizeBasedTriggeringPolicy size="500" >
                <OnStartupTriggeringPolicy />
                </SizeBasedTriggeringPolicy >

     </RollingFile>

and

    <RollingFile name="Rolling-1" fileName="logs/a.log"
                           filePattern="logs/test1-${sd:type}.%i.log.gz">
                <PatternLayout>
                  <pattern>%d %p %C [%t] %m%n</pattern> <!-- %d %p %C{1.}
[%t] %m%n -->
                </PatternLayout>
                <SizeBasedTriggeringPolicy size="500" >

                </SizeBasedTriggeringPolicy >

                 <OnStartupTriggeringPolicy />

     </RollingFile>

Where can we view the parameters for the core appenders/ policies and other
config elements?

Need some more samples fast! thank you.

On Thu, Aug 30, 2012 at 10:29 AM, Ralph Goers <[email protected]>wrote:

> I was just looking at the code and I'm not sure you are aware that the
> RollingFileAppender uses a RolloverStrategy.  You don't have to configure
> it as DefaultRolloverStrategy is used if you don't specify one.  The
> rollover strategy has  method named rollover that is passed the
> RollingFileManager.  This method takes care of actually performing the
> renaming of files, etc.  You can already extend this class and override
> that method to perform work before or after doing
> super.rollover(fileManager).
>
> Would this fulfill your need?
>
> Ralph
>
>
>
>
> On Aug 29, 2012, at 2:35 PM, Ralph Goers wrote:
>
> > Thanks for downloading Log4j 2 and working with it!
> >
> > RollingFileAppender currently doesn't support a listener but I see no
> reason it couldn't.  Feel free to create a Jira issue for this feature.  If
> you would like to implement it as well that would be fantastic!
> >
> > Ralph
> >
> > On Aug 29, 2012, at 2:26 PM, Tushar Kapila wrote:
> >
> >> Happy to have downloaded the alpha sources using wget (wget is nifty
> worked
> >> on windows too : wget -e robots=off --cut-dirs=3 -r -p -np
> >> --no-check-certificate
> >>
> https://repository.apache.org/content/repositories/orgapachelogging-009/org/apache/logging/log4j/
> )
> >> and making my first test project with log4j2 !
> >>
> >> Upgraded the conf to write to a rolling file.
> >>
> >> *Ralph : *Where can we learn about using the rolling file manager? can a
> >> class subscribe to roll events so we can do custom tasks for old files
> >> (like pack them up in to a password protected zip and store in an
> alternate
> >> location, when the number of files is more than 300 ? The listener would
> >> count the number of files etc but the log4j rolling manager should take
> >> care of 'missing files' as we would delete them after archiving). if it
> >> does not have support for this could you add it?
> >>
> >> The conf I used :
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <configuration status="debug">
> >> <appenders>
> >>   <Console name="Console" target="SYSTEM_OUT">
> >>     <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
> >> %msg%n"/>
> >>   </Console>
> >>
> >>   <RollingFile name="Rolling-1" fileName="logs/a.log"
> >>                          filePattern="logs/test1-${sd:type}.%i.log.gz">
> >>               <PatternLayout>
> >>                 <pattern>%d %p %C [%t] %m%n</pattern> <!-- %d %p %C{1.}
> >> [%t] %m%n -->
> >>               </PatternLayout>
> >>               <SizeBasedTriggeringPolicy size="500" />
> >> <!-- want to hook a class here to listen to rolling events after they
> occur
> >> -->
> >>    </RollingFile>
> >>
> >> </appenders>
> >> <loggers>
> >>   <root level="debug">
> >>     <appender-ref ref="Console"/>
> >>     <appender-ref ref="Rolling-1"/>
> >>   </root>
> >> </loggers>
> >> </configuration>
> >>
> >> *Users : *For anyone interested - here is the source of the eclipse
> project
> >> http://sel2in.com/pages/log4j/ , with config xml and java files. All it
> >> needs are the log4j jars that you can get from
> >> http://logging.apache.org/log4j/2.x/ if the site does not open try
> after an
> >> hour ... :) might be down for temporary maintenance.
> >>
> >> Regards
> >> Tushar Kapila
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Regards
Tushar Kapila

Reply via email to