1 // Module: Log4CPLUS
2 // File: nteventlogappender.h
3 // Created: 4/2003
4 // Author: Michael CATANZARITI
5 //
6 // Copyright (C) Michael CATANZARITI All rights reserved.
7 //
8 // This software is published under the terms of the Apache Software
9 // License version 1.1, a copy of which has been included with this
10 // distribution in the LICENSE.APL file.
11 //
12
13 /** @file */
14
15 #ifndef _LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
16 #define _LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
17
18 #include <log4cplus/config.h>
19 #if defined(_WIN32)
20
21 #include <log4cplus/appender.h>
22
23
24 namespace log4cplus {
25
26 /**
27 * Appends log events to NT EventLog.
28 */
29 class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender {
30 public:
31 // ctors
32 NTEventLogAppender(const log4cplus::tstring& server,
33 const log4cplus::tstring& log,
34 const log4cplus::tstring& source);
35 NTEventLogAppender(const log4cplus::helpers::Properties properties);
36
37 // dtor
38 virtual ~NTEventLogAppender();
39
40 // public Methods
41 virtual void close();
42
43 protected:
44 virtual void append(const spi::InternalLoggingEvent& event);
45 virtual WORD getEventType(const spi::InternalLoggingEvent& event);
46 virtual WORD getEventCategory(const spi::InternalLoggingEvent& event);
47 void init();
48
49 /*
50 * Add this source with appropriate configuration keys to the registry.
51 */
52 void addRegistryInfo();
53
54 // Data
55 log4cplus::tstring server;
56 log4cplus::tstring log;
57 log4cplus::tstring source;
58 HANDLE hEventLog;
59 SID* pCurrentUserSID;
60
61 private:
62 // Disallow copying of instances of this class
63 NTEventLogAppender(const NTEventLogAppender&);
64 NTEventLogAppender& operator=(const NTEventLogAppender&);
65 };
66
67 } // end namespace log4cplus
68
69 #endif // _WIN32
70 #endif //_LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
syntax highlighted by Code2HTML, v. 0.9.1