-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distribute log4jna in Maven central #6
Comments
Disregard... bad assumption. The included artifacts are okay, it was my installed jars that are the older version. Sorry! |
Are the log4jna artifacts hosted in a maven repo somewhere, so I could just add the dependency to my pom? I couldn't find one.... |
There's no log4jna in Maven, I would love it if someone took care of that (mavenize build, push to maven central ...), contributors welcome. |
Just a suggestion: If you are interested about change the project building, take a look first at Gradle (https://www.gradle.org/). It uses the "task" concept like Ant and the building script is a Groovy script (no XML programming). See ya. |
I did set up a Maven build for the Java piece - I needed to make EventId customizable rather than 4096 every time, so I added that to the Java class - but I can't build the Windows DLL because the src zip is missing "version.rc.template". I don't think it will be that hard to "Mavenize" the Windows DLL build via the Maven antrun plugin - you can pretty much copy and paste the ant tasks, and I had the "mc" task working through Maven. Packaging the whole thing so that it is usable may be a different problem. One distribution containing the JAR and DLL? One each? I'm a C# developer relatively new to Java and Maven, so I'm still experimenting. |
We have maven hosting set up on Sonatype. https://issues.sonatype.org/browse/OSSRH-23287. I will work on this and CI #10 simultaneously. |
Your user and a new user Log4JNACI have been added to I will change the setting.xml file to use Log4JNACI for Maven. |
There are a few tasks before we are ready for Maven Cenetral. CI:
Code clean up and update:
|
I noticed that #3 refers to the location of the log in the EventLogger tree as Application, but the code expects a parameter called Some of the log4j.xml examples in the discussions use As I see it:
Is a catch all location if you are not using:
I also would like to change the code in Right now the code only tries to create the key and if it fails gives up, I might be wrong, but I think that if we try to change a value the code will fail because This is how it looks: private static HANDLE registerEventSource(String server, String source, String application, String eventMessageFile,
String categoryMessageFile) {
String eventSourceKeyPath = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\" + application + "\\" + source;
if (Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath)) {
// Test dll location, and source here and change the values if they differ from the current ones
} else {
if (Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath)) {
Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, "TypesSupported", 7);
Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, "CategoryCount", 6);
Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, "EventMessageFile",
eventMessageFile);
Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath,
"CategoryMessageFile", categoryMessageFile);
}
}
HANDLE h = Advapi32.INSTANCE.RegisterEventSource(server, source);
if (h == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return h;
} BTW Is there any reason for this to be static? |
I don't have strong opinions about any of this above, it has been a while since I looked at this. |
… update of dll location Form dblock#23#issuecomment-232184331 Deleted seting-security.xml
I'm ready to rel;ease.
|
@claudiow Go for it! |
Done, It took some work. I will update the documentation with what I found. |
The jna.jar and platform.jar that are included in the log4jna-1.3zip archive appear to be JNA v3.2.7 artifacts, but the Win32EventLogAppender has code that depends on JNA v4.1.
Specifically, line 238:
if (Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath))
Platform v3.2.7 returns void from that method, which leads to runtime errors:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: com.sun.jna.platform.win32.Advapi32Util.registryCreateKey(Lcom/sun/jna/platform/win32/WinReg$HKEY;Ljava/lang/String;)Z
at org.apache.log4jna.nt.Win32EventLogAppender.registerEventSource(Unknown Source)
at org.apache.log4jna.nt.Win32EventLogAppender.registerEventSource(Unknown Source)
at org.apache.log4jna.nt.Win32EventLogAppender.append(Unknown Source)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.info(Category.java:666)
... redacted...
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
The text was updated successfully, but these errors were encountered: