/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if !defined(_LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H) #define _LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H #include namespace log4cxx { namespace rolling { /** * RollingFileAppender extends {@link log4cxx::FileAppender} to backup the log files * depending on {@link log4cxx::rolling::RollingPolicy RollingPolicy} and {@link log4cxx::rolling::TriggeringPolicy TriggeringPolicy}. *

* To be of any use, a RollingFileAppender instance must have both * a RollingPolicy and a TriggeringPolicy set up. * However, if its RollingPolicy also implements the * TriggeringPolicy interface, then only the former needs to be * set up. For example, {@link log4cxx::rolling::TimeBasedRollingPolicy TimeBasedRollingPolicy} acts both as a * RollingPolicy and a TriggeringPolicy. * *

RollingFileAppender can be configured programattically or * using {@link log4cxx::xml::DOMConfigurator}. Here is a sample * configration file:

<?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE log4j:configuration>

        <log4j:configuration debug="true">

          <appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender">
            <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
              <param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/>
            </rollingPolicy>

            <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%c{1} - %m%n"/>
            </layout>
          </appender>

          <root">
            <appender-ref ref="ROLL"/>
          </root>

        </log4j:configuration>
        
*

This configuration file specifies a monthly rollover schedule including * automatic compression of the archived files. See * {@link TimeBasedRollingPolicy} for more details. * * * * * */ class LOG4CXX_EXPORT RollingFileAppender : public RollingFileAppenderSkeleton { DECLARE_LOG4CXX_OBJECT(RollingFileAppender) BEGIN_LOG4CXX_CAST_MAP() LOG4CXX_CAST_ENTRY(RollingFileAppender) LOG4CXX_CAST_ENTRY_CHAIN(RollingFileAppenderSkeleton) END_LOG4CXX_CAST_MAP() public: RollingFileAppender(); using RollingFileAppenderSkeleton::getRollingPolicy; using RollingFileAppenderSkeleton::getTriggeringPolicy; /** * Sets the rolling policy. In case the 'policy' argument also implements * {@link TriggeringPolicy}, then the triggering policy for this appender * is automatically set to be the policy argument. * @param policy */ using RollingFileAppenderSkeleton::setRollingPolicy; using RollingFileAppenderSkeleton::setTriggeringPolicy; }; LOG4CXX_PTR_DEF(RollingFileAppender); } } #endif