Apache Log4cxx  Version 1.7.0
fileappender.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 #ifndef _LOG4CXX_FILE_APPENDER_H
19 #define _LOG4CXX_FILE_APPENDER_H
20 
21 #include <log4cxx/logger.h>
22 #include <log4cxx/logstring.h>
23 #include <log4cxx/writerappender.h>
24 #include <log4cxx/file.h>
25 #include <log4cxx/helpers/pool.h>
26 
27 namespace LOG4CXX_NS
28 {
29 namespace helpers
30 {
31 class Pool;
32 }
33 
44 class LOG4CXX_EXPORT FileAppender : public WriterAppender
45 {
46  protected:
47  struct FileAppenderPriv;
48 
49  public:
55 
56 
60 
74  FileAppender(const LayoutPtr& layout, const LogString& filename, bool append,
75  bool bufferedIO, int bufferSize);
76 
86  FileAppender(const LayoutPtr& layout, const LogString& filename, bool append);
87 
94  FileAppender(const LayoutPtr& layout, const LogString& filename);
95 
97 
107  virtual void setFile(const LogString& file);
108 
112  bool getAppend() const;
113 
115  LogString getFile() const;
116 
126  void activateOptions(helpers::Pool& p) override;
127 
147  void setOption(const LogString& option, const LogString& value) override;
148 
155  bool getBufferedIO() const;
156 
160  int getBufferSize() const;
161 
166  int getBufferedSeconds() const;
167 
180  void setAppend(bool newValue);
181 
196  void setBufferedIO(bool newValue);
197 
201  void setBufferSize(int newValue);
202 
210  void setBufferedSeconds(int newValue);
211 
218  static LogString stripDuplicateBackslashes(const LogString& name);
219 
220  protected:
221  void activateOptionsInternal(helpers::Pool& p);
222 
243  void setFileInternal(const LogString& file, bool append,
244  bool bufferedIO, size_t bufferSize,
245  helpers::Pool& p);
246 
247  void setFileInternal(const LogString& file);
248 
249  private:
250  FileAppender(const FileAppender&);
251  FileAppender& operator=(const FileAppender&);
252  protected:
253  FileAppender(std::unique_ptr<FileAppenderPriv> priv);
254 
255 }; // class FileAppender
257 
258 } // namespace log4cxx
259 
260 #endif
FileAppender appends log events to a file.
Definition: fileappender.h:45
WriterAppender appends log events to a standard output stream.
Definition: writerappender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:60
LOG4CXX_PTR_DEF(FileAppender)
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:41
#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