Apache Log4cxx  Version 1.1.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
29 {
30 namespace rolling
31 {
32 
33 
79 class LOG4CXX_EXPORT RollingFileAppender : public FileAppender
80 {
86  protected:
87  struct RollingFileAppenderPriv;
88 
89  public:
91 
93  int getMaxBackupIndex() const;
94 
96  size_t getMaximumFileSize() const;
97 
98 
107  void setMaxBackupIndex( int maxBackupIndex );
108 
117  void setMaxFileSize( const LogString& value );
118 
119  void setMaximumFileSize( size_t value );
120 
126  void setDatePattern(const LogString& pattern);
127 
129 
130  void setOption( const LogString& option, const LogString& value ) override;
131 
133  void activateOptions(helpers::Pool& pool ) override;
134 
150 
151  protected:
152 
156  void subAppend(const spi::LoggingEventPtr& event, helpers::Pool& p) override;
157 
159 
160  public:
164  RollingPolicyPtr getRollingPolicy() const;
165 
169  TriggeringPolicyPtr getTriggeringPolicy() const;
170 
178  void setRollingPolicy(const RollingPolicyPtr& policy);
179 
183  void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
184 
185  public:
189  void close() override;
190 
191  protected:
201  helpers::WriterPtr createWriter(helpers::OutputStreamPtr& os) override;
202 
203  public:
208  size_t getFileLength() const;
209 
214  void incrementFileLength(size_t increment);
215 
216 };
217 
219 
220 }
221 }
222 
223 #endif
224 
FileAppender appends log events to a file.
Definition: fileappender.h:42
Definition: pool.h:33
RollingFileAppender extends log4cxx::FileAppender to backup the log files depending on RollingPolicy ...
Definition: rollingfileappender.h:80
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...
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)
Implements the usual roll over behaviour.
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.
bool rolloverInternal(log4cxx::helpers::Pool &p)
void setRollingPolicy(const RollingPolicyPtr &policy)
Use policy as the scheme for rolling over log files.
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.
helpers::WriterPtr createWriter(helpers::OutputStreamPtr &os) override
Returns an OutputStreamWriter when passed an OutputStream.
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.
void activateOptions(helpers::Pool &pool) override
Prepares RollingFileAppender for use.
int getMaxBackupIndex() const
Returns the value of the MaxBackupIndex option.
LOG4CXX_PTR_DEF(Action)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:31
Definition: appender.h:27
std::basic_string< logchar > LogString
Definition: logstring.h:60
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:42
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:163
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145