clojure-emacs / logjam

An interactive, nrepl-oriented logging backend
Eclipse Public License 1.0
1 stars 0 forks source link

Log4j2 compatibility #2

Open vemv opened 1 year ago

vemv commented 1 year ago

Context

https://github.com/clojure-emacs/cider-nrepl/pull/773#discussion_r1226611259

Brief

Right now this works with Logback (which I am using) and Java Util Logging. There is some code for Log4j2 that passes some of the tests, but I couldn't make it working reliably. The issue seems that Log4j2 reloads its configuration when a new appender is added, and wipes out the changes. I tried most of the suggestions on Stackoverflow to get it working, but I'm giving up on this one. I already spent too much time on this. So, I propose to drop that code into a branch of the separated library. If anyone knows how to get it working, I'm willing to help, but I won't investigate this beast any further.

Possible solutions

Would it help if the nrepl logger wasn't dynamically added? e.g. one could configure it such that it's instantiated as the JVM starts. This would probably involve a .xml file or a user.clj file. ...this would not invalidate the current, dynamic approach, I'd see it instead of an additional, opt-in manner to run things.

It might, but I believe for this to work we would need to use gen-class to create an appender class that implements some Log4j2 interface and ship it, so that it can be referenced in the configuration file. And then somehow connect this with the atom to which events are added.

r0man commented 1 year ago

I did some experiments with Log4j2 which I pushed into this branch: https://github.com/clojure-emacs/logjam/tree/log4j2