dblock / log4jna

Log4jna is a library of native appenders for log4j.
Apache License 2.0
27 stars 17 forks source link

Configuring different event IDs for logged messages. #244

Open gosub3000 opened 6 months ago

gosub3000 commented 6 months ago

Hi, When logging messages through log4jna every event in the Windows Event Viewer has the same event ID (4096). Is it possible to specify different IDs per message, and if so how?

Kind regards, Chris

dblock commented 6 months ago

I had written https://code.dblock.org/2010/10/14/log4jna-the-description-for-event-id-4096-from-source-log4jna-cannot-be-found.html to explain what this ID is, check it out?

The message ID is hardcoded in https://github.com/dblock/log4jna/blob/db139770edb45c83be05ecddea912a24f45d8b8b/log4jna-api/src/main/java/org/dblock/log4jna/nt/Win32EventLogAppender.java#L259. You'd need to expose that, but that obviously will have other consequences on rendering messages.

PRs welcome!

sergueik commented 5 months ago

one can use %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll and make eventid an appender property - has templates for arbitrary if one does not want to have to create one can pic existing id / application /service / Message Category resource dll e.g.

1000 Application Application Error wer.dll

the quick brown fox jumps over the lazy dog

see the logback backed https://github.com/sergueik/springboot_study/tree/master/basic-logback-eventlog and standalone https://github.com/sergueik/springboot_study/tree/master/basic-jna-eventlog

wips of mine

the https://github.com/sergueik/springboot_study/tree/master/basic-log4j-eventlog is where I prepare the PR