Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
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>
24#include <log4cxx/file.h>
25
26namespace LOG4CXX_NS
27{
28
43class LOG4CXX_EXPORT FileAppender : public WriterAppender
44{
45 protected:
46 struct FileAppenderPriv;
47
48 public:
54
55
59
73 ( const LayoutPtr& layout
74 , const LogString& fileName
75 , bool appendToExistingFile = true
76 , bool useBufferedOutput = false
77 , int bufferByteCount = DefaultBufferedByteCount
78 );
79
81
91 void setFile(const LogString& file);
92
96 bool getAppend() const;
97
100
113 void activateOptions( ) override;
114
135 void setOption(const LogString& option, const LogString& value) override;
136
143 bool getBufferedIO() const;
144
148 int getBufferSize() const;
149
155
168 void setAppend(bool newValue);
169
184 void setBufferedIO(bool newValue);
185
189 void setBufferSize(int newValue);
190
198 void setBufferedSeconds(int newValue);
199
208 void setLazyFileCreation(bool newValue);
209
214
222
223 static const int DefaultBufferedByteCount = 8 * 1024;
224 private:
226 FileAppender& operator=(const FileAppender&);
227 protected:
228 FileAppender(std::unique_ptr<FileAppenderPriv> priv);
229
230}; // class FileAppender
232
233} // namespace log4cxx
234
235#endif
FileAppender appends log events to a file.
Definition fileappender.h:44
void setOption(const LogString &option, const LogString &value) override
Set option to value.
int getBufferSize() const
Get the size of the IO buffer.
void setAppend(bool newValue)
Set file open mode to newValue.
void setBufferedIO(bool newValue)
Set buffered output behavior to newValue.
LogString getFile() const
Returns the value of the File option.
void setLazyFileCreation(bool newValue)
Create the file when the first message is written (rather than in activateOptions) if newValue is tru...
void activateOptions() override
Derived appenders should override this method if option structure requires it.
bool getLazyFileCreation() const
Get the value of the LazyFileCreation option.
static const int DefaultBufferedByteCount
Definition fileappender.h:223
static LogString stripDuplicateBackslashes(const LogString &name)
Replaces double backslashes with single backslashes for compatibility with paths from earlier XML con...
FileAppender()
An unconfigured Appender.
bool getBufferedIO() const
Get the value of the BufferedIO option.
void setFile(const LogString &file)
The File property takes a string value which should be the name of the file to append to.
int getBufferedSeconds() const
Get the number of seconds between file writes when the BufferedIO option is true.
void setBufferSize(int newValue)
Use newValue as the size of the output buffer.
bool getAppend() const
Returns the value of the Append option.
void setBufferedSeconds(int newValue)
Flush the output buffer every newValue seconds.
WriterAppender()
An uninitialised Appender.
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Layout > LayoutPtr
Definition appender.h:42
LOG4CXX_PTR_DEF(Appender)
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define DECLARE_LOG4CXX_OBJECT(object)
Definition object.h:41
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:159
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141