@Plugin(name="Win32EventLog", category="Core", elementType="appender", printObject=true) public class Win32EventLogAppender extends AbstractAppender
WARNING This appender can only be installed and used on a Windows system.
Do not forget to place jna.jar and platform.jar in the CLASSPATH.
AbstractAppender.Builder<B extends AbstractAppender.Builder<B>>LifeCycle.State| Modifier and Type | Field and Description |
|---|---|
private String |
_application |
private String |
_categoryMessageFile |
private String |
_eventMessageFile |
private WinNT.HANDLE |
_handle |
private String |
_server |
private String |
_source |
private static int |
CATEGORY_COUNT |
private static String |
CATEGORY_MESSAGE_FILE |
private static String |
DEFAULT_APPLICATION |
private static String |
DEFAULT_SOURCE |
private static String |
EVENT_LOG_PATH |
private static String |
EVENT_MESSAGE_FILE |
private static int |
TYPES_SUPPORTED |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGERELEMENT_TYPE, EMPTY_ARRAY| Constructor and Description |
|---|
Win32EventLogAppender(String name,
String server,
String source,
String application,
String eventMessageFile,
String categoryMessageFile,
Layout<? extends Serializable> layout,
Filter filter) |
| Modifier and Type | Method and Description |
|---|---|
void |
activateOptions() |
void |
append(LogEvent event) |
void |
close() |
private void |
createAndSetAllKeys(String eventMessageFile,
String categoryMessageFile,
String eventSourceKeyPath) |
static Win32EventLogAppender |
createAppender(String name,
String server,
String source,
String application,
String eventMessageFile,
String categoryMessageFile,
Layout<? extends Serializable> layout,
Filter filter) |
void |
finalize() |
String |
getApplication() |
String |
getCategoryMessageFile() |
private static int |
getEventLogCategory(Level level)
Convert log4j Priority to an EventLog category.
|
private static int |
getEventLogType(Level level)
Convert log4j Priority to an EventLog type.
|
String |
getEventMessageFile() |
String |
getSource() |
private void |
registerEventSource() |
private WinNT.HANDLE |
registerEventSource(String server,
String source,
String application,
String eventMessageFile,
String categoryMessageFile) |
boolean |
requiresLayout()
The
Win32EventLogAppender requires a layout. |
void |
setApplication(String application)
The Application option which names the subsection of the
'Applications and Services Log'.
|
void |
setCategoryMessageFile(String categoryMessageFile)
The CategoryMessageFile option which sets file location of the
Catagory Messages
|
void |
setEventMessageFile(String eventMessageFile)
The EventMessageFile option which sets file location of the Event
Messages
|
void |
setSource(String source)
The Source option which names the source of the event.
|
private void |
setVariableKeys(String eventMessageFile,
String categoryMessageFile,
String eventSourceKeyPath)
Set the file location only if it does not exist or has changed.
|
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toStringaddFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop, stopequalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stopprivate static final String EVENT_LOG_PATH
private static final String CATEGORY_MESSAGE_FILE
private static final String EVENT_MESSAGE_FILE
private static final int CATEGORY_COUNT
private static final int TYPES_SUPPORTED
private static final String DEFAULT_SOURCE
private static final String DEFAULT_APPLICATION
private String _source
private String _server
private String _application
private String _eventMessageFile
private String _categoryMessageFile
private WinNT.HANDLE _handle
public Win32EventLogAppender(String name, String server, String source, String application, String eventMessageFile, String categoryMessageFile, Layout<? extends Serializable> layout, Filter filter)
name - The appender name Win32EventLogserver - The server for remote loggingsource - The Event View Sourceapplication - The Event View application (location)eventMessageFile - The message file location in the file systemcategoryMessageFile - The message file location in the file systemlayout - A Log4j Layoutfilter - A Log4j Filter@PluginFactory public static Win32EventLogAppender createAppender(@PluginAttribute(value="name") String name, @PluginAttribute(value="server") String server, @PluginAttribute(value="source") String source, @PluginAttribute(value="application") String application, @PluginAttribute(value="eventMessageFile") String eventMessageFile, @PluginAttribute(value="categoryMessageFile") String categoryMessageFile, @PluginElement(value="Layout") Layout<? extends Serializable> layout, @PluginElement(value="Filters") Filter filter)
name - The appender name Win32EventLogserver - The server for remote loggingsource - The Event View Sourceapplication - The Event View application (location)eventMessageFile - The message file location in the file systemcategoryMessageFile - The message file location in the file systemlayout - A Log4j Layoutfilter - A Log4j Filterpublic void setSource(String source)
public String getSource()
public void setApplication(String application)
application - The Event View application (location)public String getApplication()
public void close()
public void setEventMessageFile(String eventMessageFile)
eventMessageFile - The message file location in the file systempublic String getEventMessageFile()
public void setCategoryMessageFile(String categoryMessageFile)
categoryMessageFile - The message file location in the file systempublic String getCategoryMessageFile()
private void registerEventSource()
public void activateOptions()
public void append(LogEvent event)
public boolean requiresLayout()
Win32EventLogAppender requires a layout. Hence, this
method always returns true.private WinNT.HANDLE registerEventSource(String server, String source, String application, String eventMessageFile, String categoryMessageFile)
server - The server for remote loggingsource - The Event View Sourceapplication - The Event View application (location)eventMessageFile - The message file location in the file systemcategoryMessageFile - The message file location in the file systemprivate void createAndSetAllKeys(String eventMessageFile, String categoryMessageFile, String eventSourceKeyPath)
eventMessageFile - The message file location in the file systemcategoryMessageFile - The message file location in the file systemeventSourceKeyPath - The registry pathprivate void setVariableKeys(String eventMessageFile, String categoryMessageFile, String eventSourceKeyPath)
eventMessageFile - The message file location in the file systemcategoryMessageFile - The message file location in the file systemeventSourceKeyPath - The registry pathprivate static int getEventLogType(Level level)
level - Log4j priority.private static int getEventLogCategory(Level level)
level - Log4J priority.Copyright © 2022 The Log4JNA Team. All rights reserved.