Apache log4cxx Version 0.13.0
Loading...
Searching...
No Matches
nteventlogappender.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_NT_EVENT_LOG_APPENDER_HEADER_
19#define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
20
22
23#if defined(_MSC_VER)
24 #pragma warning ( push )
25 #pragma warning ( disable: 4251 )
26#endif
27
28
29namespace log4cxx
30{
31namespace nt
32{
36class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSkeleton
37{
38 public:
44
46 NTEventLogAppender(const LogString& server, const LogString& log,
47 const LogString& source, const LayoutPtr& layout);
48
50
51 virtual void activateOptions(log4cxx::helpers::Pool& p);
52 virtual void close();
53 virtual void setOption(const LogString& option, const LogString& value);
54
60 bool requiresLayout() const
61 {
62 return true;
63 }
64
65 void setSource(const LogString& source)
66 {
67 this->source.assign(source);
68 }
69
70 const LogString& getSource() const
71 {
72 return source;
73 }
74
75 void setLog(const LogString& log)
76 {
77 this->log.assign(log);
78 }
79
80 const LogString& getLog() const
81 {
82 return log;
83 }
84
85 void setServer(const LogString& server)
86 {
87 this->server.assign(server);
88 }
89
90 const LogString& getServer() const
91 {
92 return server;
93 }
94
95
96 protected:
97 //
98 // these typedef are proxies for the real Win32 definitions
99 // and need to be cast to the global definitions before
100 // use with a Win32 API call
101 typedef void SID;
102 typedef void* HANDLE;
103
104 virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
105 static unsigned short getEventType(const spi::LoggingEventPtr& event);
106 static unsigned short getEventCategory(const spi::LoggingEventPtr& event);
107 /*
108 * Add this source with appropriate configuration keys to the registry.
109 */
111
112 // Data
118 static LogString getErrorString(const LogString& function);
119
120 private:
122 NTEventLogAppender& operator=(const NTEventLogAppender&);
123}; // class NTEventLogAppender
124
126
127} // namespace nt
128} // namespace log4cxx
129
130#if defined(_MSC_VER)
131 #pragma warning (pop)
132#endif
133#endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
Implementation base class for all appenders.
Definition: appenderskeleton.h:46
Definition: pool.h:33
Appends log events to NT EventLog.
Definition: nteventlogappender.h:37
void setLog(const LogString &log)
Definition: nteventlogappender.h:75
void * HANDLE
Definition: nteventlogappender.h:102
const LogString & getServer() const
Definition: nteventlogappender.h:90
static unsigned short getEventType(const spi::LoggingEventPtr &event)
const LogString & getLog() const
Definition: nteventlogappender.h:80
void setServer(const LogString &server)
Definition: nteventlogappender.h:85
virtual void append(const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)
Subclasses of AppenderSkeleton should implement this method to perform actual logging.
HANDLE hEventLog
Definition: nteventlogappender.h:116
LogString source
Definition: nteventlogappender.h:115
LogString server
Definition: nteventlogappender.h:113
LogString log
Definition: nteventlogappender.h:114
static LogString getErrorString(const LogString &function)
const LogString & getSource() const
Definition: nteventlogappender.h:70
void setSource(const LogString &source)
Definition: nteventlogappender.h:65
void SID
Definition: nteventlogappender.h:101
static unsigned short getEventCategory(const spi::LoggingEventPtr &event)
SID * pCurrentUserSID
Definition: nteventlogappender.h:117
LOG4CXX_PTR_DEF(NTEventLogAppender)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:38
Definition: messagehandler.h:23
std::basic_string< logchar > LogString
Definition: logstring.h:66
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:48
#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:39
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:159
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141