Apache log4cxx  Version 0.12.1
syslogappender.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_NET_SYSLOG_APPENDER_H
19 #define _LOG4CXX_NET_SYSLOG_APPENDER_H
20 
23 
24 #if defined(_MSC_VER)
25  #pragma warning ( push )
26  #pragma warning ( disable: 4251 )
27 #endif
28 
29 namespace log4cxx
30 {
31 namespace net
32 {
46 class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleton
47 {
48  public:
54 
55 
56 
58  SyslogAppender(const LayoutPtr& layout, int syslogFacility);
59  SyslogAppender(const LayoutPtr& layout,
60  const LogString& syslogHost, int syslogFacility);
61  ~SyslogAppender();
63  void close();
64 
69  static LogString getFacilityString(int syslogFacility);
70 
79  static int getFacility(const LogString& facilityName);
80 
81  void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
82 
87  void activateOptions(log4cxx::helpers::Pool& p);
88  void setOption(const LogString& option, const LogString& value);
89 
94  virtual bool requiresLayout() const
95  {
96  return true;
97  }
98 
105  void setSyslogHost(const LogString& syslogHost);
106 
110  inline const LogString& getSyslogHost() const
111  {
112  return syslogHost;
113  }
114 
123  void setFacility(const LogString& facilityName);
124 
128  inline LogString getFacility() const
129  {
130  return getFacilityString(syslogFacility);
131  }
132 
138  inline void setFacilityPrinting(bool facilityPrinting1)
139  {
140  this->facilityPrinting = facilityPrinting1;
141  }
142 
146  inline bool getFacilityPrinting() const
147  {
148  return facilityPrinting;
149  }
150 
151  inline void setMaxMessageLength(int maxMessageLength1)
152  {
153  maxMessageLength = maxMessageLength1;
154  }
155 
156  inline int getMaxMessageLength() const
157  {
158  return maxMessageLength;
159  }
160 
161  protected:
162  void initSyslogFacilityStr();
163 
164  int syslogFacility; // Have LOG_USER as default
171  private:
173  SyslogAppender& operator=(const SyslogAppender&);
174 }; // class SyslogAppender
176 } // namespace net
177 } // namespace log4cxx
178 
179 #if defined(_MSC_VER)
180  #pragma warning (pop)
181 #endif
182 
183 #endif // _LOG4CXX_NET_SYSLOG_APPENDER_H
184 
LogString syslogHost
Definition: syslogappender.h:168
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
bool facilityPrinting
Definition: syslogappender.h:166
const LogString & getSyslogHost() const
Returns the value of the SyslogHost option.
Definition: syslogappender.h:110
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
Implementation base class for all appenders.
Definition: appenderskeleton.h:43
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
int getMaxMessageLength() const
Definition: syslogappender.h:156
helpers::SyslogWriter * sw
Definition: syslogappender.h:167
void setMaxMessageLength(int maxMessageLength1)
Definition: syslogappender.h:151
SyslogWriter is a wrapper around the DatagramSocket class it writes text to the specified host on the...
Definition: syslogwriter.h:39
LogString facilityStr
Definition: syslogappender.h:165
void setFacilityPrinting(bool facilityPrinting1)
If the FacilityPrinting option is set to true, the printed message will include the facility name of ...
Definition: syslogappender.h:138
int syslogFacility
Definition: syslogappender.h:164
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:47
bool getFacilityPrinting() const
Returns the value of the FacilityPrinting option.
Definition: syslogappender.h:146
Definition: pool.h:32
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:154
Use SyslogAppender to send log messages to a remote syslog daemon.
Definition: syslogappender.h:46
LogString getFacility() const
Returns the value of the Facility option.
Definition: syslogappender.h:128
LOG4CXX_PTR_DEF(SMTPAppender)
int syslogHostPort
Definition: syslogappender.h:169
virtual bool requiresLayout() const
The SyslogAppender requires a layout.
Definition: syslogappender.h:94
int maxMessageLength
Definition: syslogappender.h:170
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66