Apache Log4cxx  Version 1.8.0
rollingfileappender.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #if !defined(_LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H)
19 #define _LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_H
20 
21 #include <log4cxx/fileappender.h>
23 #include <log4cxx/fileappender.h>
26 #include <log4cxx/rolling/action.h>
27 
28 namespace LOG4CXX_NS
29 {
30 namespace rolling
31 {
32 
33 
76 class LOG4CXX_EXPORT RollingFileAppender : public FileAppender
77 {
83  protected:
84  struct RollingFileAppenderPriv;
85 
86  public:
88  RollingFileAppender( std::unique_ptr<RollingFileAppenderPriv> priv );
89 
91  int getMaxBackupIndex() const;
92 
94  size_t getMaximumFileSize() const;
95 
96 
105  void setMaxBackupIndex( int maxBackupIndex );
106 
115  void setMaxFileSize( const LogString& value );
116 
117  void setMaximumFileSize( size_t value );
118 
124  void setDatePattern(const LogString& pattern);
125 
127 
148  void setOption( const LogString& option, const LogString& value ) override;
149 
150  using spi::OptionHandler::activateOptions;
157 
172  bool rollover();
173 #if LOG4CXX_ABI_VERSION <= 15
174  bool rollover(LOG4CXX_NS::helpers::Pool& p);
175 #endif
176 
177  protected:
178 
183 
185 #if LOG4CXX_ABI_VERSION <= 15
186  bool rolloverInternal(LOG4CXX_NS::helpers::Pool& p);
187 #endif
188 
189  public:
193  RollingPolicyPtr getRollingPolicy() const;
194 
198  TriggeringPolicyPtr getTriggeringPolicy() const;
199 
207  void setRollingPolicy(const RollingPolicyPtr& policy);
208 
212  void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
213 
214  public:
218  void close() override;
219 
220  protected:
230  helpers::WriterPtr createWriter(LOG4CXX_16_CONST helpers::OutputStreamPtr& os) override;
231 
232  public:
237  size_t getFileLength() const;
238 
243  void incrementFileLength(size_t increment);
244 
245 };
246 
248 
249 }
250 }
251 
252 #endif
253 
#define LOG4CXX_APPEND_FORMAL_PARAMETERS
Log in Appender specific way.
Definition: appender.h:92
FileAppender appends log events to a file.
Definition: fileappender.h:45
RollingFileAppender extends log4cxx::FileAppender to backup the log files depending on RollingPolicy ...
Definition: rollingfileappender.h:77
void setTriggeringPolicy(const TriggeringPolicyPtr &policy)
Use policy to determine when to trigger a log file rollover.
size_t getMaximumFileSize() const
Get the maximum size that the output file is allowed to reach before being rolled over to backup file...
helpers::WriterPtr createWriter(LOG4CXX_16_CONST helpers::OutputStreamPtr &os) override
Returns an OutputStreamWriter when passed an OutputStream.
bool rollover()
Implements the configured roll over behaviour.
void close() override
Close appender.
void incrementFileLength(size_t increment)
Increments estimated byte length of current active log file.
bool rollover(log4cxx::helpers::Pool &p)
void subAppend(const spi::LoggingEventPtr &event, helpers::Pool &p) override
Actual writing occurs here.
TriggeringPolicyPtr getTriggeringPolicy() const
The policy that determine when to trigger a log file rollover.
RollingFileAppender(std::unique_ptr< RollingFileAppenderPriv > priv)
bool rolloverInternal(log4cxx::helpers::Pool &p)
void setRollingPolicy(const RollingPolicyPtr &policy)
Use policy as the scheme for rolling over log files.
void activateOptions(helpers::Pool &p) override
Derived appenders should override this method if option structure requires it.
LogString makeFileNamePattern(const LogString &datePattern)
size_t getFileLength() const
Get byte length of current active log file.
void setMaxBackupIndex(int maxBackupIndex)
Set the maximum number of backup files to keep around.
RollingPolicyPtr getRollingPolicy() const
The policy that implements the scheme for rolling over a log file.
void setMaxFileSize(const LogString &value)
Set the maximum size that the output file is allowed to reach before being rolled over to backup file...
void setOption(const LogString &option, const LogString &value) override
Set option to value.
void setDatePattern(const LogString &pattern)
The DatePattern takes a string in the same format as expected by SimpleDateFormat.
int getMaxBackupIndex() const
Returns the value of the MaxBackupIndex option.
LOG4CXX_PTR_DEF(RollingFileAppender)
std::basic_string< logchar > LogString
Definition: logstring.h:60
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:154
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:148
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:41
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:160
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:142
#define LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS
Activate the options that were previously set with calls to option setters.
Definition: optionhandler.h:53
#define LOG4CXX_16_CONST
Definition: outputstreamwriter.h:28