The first time you run the test suite or any application using Log4JNA, Log4JNA attempts to write the necessary entries in WindowsTM Registry. If you don't have administrator privileges the run fails.
In order for the tests to pass you must run them as Administrator or set up the registry before your first run.
Open a command window as administrator and execute mvn test
If you are using an IDE launch it as Administrator import the Maven projects and run the tests.
Please be careful and do not check IDE configuration files into GitHub, you can add the project to your IDE following the instructions bellow.
Eclipse configuration files are already added to .gitignore
, please add any configuration file created by your IDE to the ignore file.
See this article to import the Maven projects.
See this article to import the Maven projects.
See this article to import the Maven projects.
The Win32EventlogAppender.dll
file is provided in the source as a test asset in
<project-location>/log4jna-api/src/test/resources
The tests configure Log4J programmatically and write into Event Viewer-->Windows Logs-->Application
regedit
and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\
New Key
, name it Log4jnaTest
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest
Entry name | Entry Type | Value |
---|---|---|
TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 |
CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 |
EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll |
CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll |
The registry should look like this:
The Win32EventlogAppender.dll
and Log4J 2 configuration files are provided in the source as an application asset in
<project-location>/log4jna-demo/src/main/resources
The default Log4J configuration is log4j2.xml
and writes into Event Viewer-->Application and Service Logs-->Win32LogApplication
regedit
and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\
New Key
, name it Win32LogApplication
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication
, name it WinLogger
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger
Entry name | Entry Type | Value |
---|---|---|
TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 |
CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 |
EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll |
CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll |
The registry should look like this: