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 size_t getBufferSize() const;
149
155
168 void setAppend(bool newValue);
169
184 void setBufferedIO(bool newValue);
185
186 static const size_t MaxBufferedByteCount = 2LL * 1024 * 1024 * 1024;
190 void setBufferSize(size_t newValue);
191
199 void setBufferedSeconds(int newValue);
200
209 void setLazyFileCreation(bool newValue);
210
215
223
224 static const int DefaultBufferedByteCount = 8 * 1024;
225 private:
227 FileAppender& operator=(const FileAppender&);
228 protected:
229 FileAppender(std::unique_ptr<FileAppenderPriv> priv);
230
231}; // class FileAppender
233
234} // namespace log4cxx
235
236#endif
FileAppender appends log events to a file.
Definition fileappender.h:44
void setOption(const LogString &option, const LogString &value) override
Override this method to set option to value.
void setAppend(bool newValue)
Set file open mode to newValue.
void setBufferSize(size_t newValue)
Use newValue, a value up to 2^31, as the size of the output buffer.
void setBufferedIO(bool newValue)
Set buffered output behavior to newValue.
static const size_t MaxBufferedByteCount
Definition fileappender.h:186
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:224
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.
bool getAppend() const
Returns the value of the Append option.
void setBufferedSeconds(int newValue)
Flush the output buffer every newValue seconds.
size_t getBufferSize() const
Get the size of the IO buffer.
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