@Plugin(name="Win32EventLog",
category="Core",
elementType="appender",
printObject=true)
public class Win32EventLogAppender
extends org.apache.logging.log4j.core.appender.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.
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 |
Constructor and Description |
---|
Win32EventLogAppender(String name,
String server,
String source,
String application,
String eventMessageFile,
String categoryMessageFile,
org.apache.logging.log4j.core.Layout<? extends Serializable> layout,
org.apache.logging.log4j.core.Filter filter) |
Modifier and Type | Method and Description |
---|---|
void |
activateOptions() |
void |
append(org.apache.logging.log4j.core.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,
org.apache.logging.log4j.core.Layout<? extends Serializable> layout,
org.apache.logging.log4j.core.Filter filter) |
void |
finalize() |
String |
getApplication() |
String |
getCategoryMessageFile() |
private static int |
getEventLogCategory(org.apache.logging.log4j.Level level)
Convert log4j Priority to an EventLog category.
|
private static int |
getEventLogType(org.apache.logging.log4j.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, toString
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop, stop
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
private 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, org.apache.logging.log4j.core.Layout<? extends Serializable> layout, org.apache.logging.log4j.core.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") org.apache.logging.log4j.core.Layout<? extends Serializable> layout, @PluginElement(value="Filters") org.apache.logging.log4j.core.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(org.apache.logging.log4j.core.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(org.apache.logging.log4j.Level level)
level
- Log4j priority.private static int getEventLogCategory(org.apache.logging.log4j.Level level)
level
- Log4J priority.Copyright © 2024 The Log4JNA Team. All rights reserved.