jhannes / logevents

An easy-to-extend implementation of SLF4J with batteries included and sensible defaults
Other
42 stars 8 forks source link

Support threshold on FileLogEventObserver #77

Closed norrs closed 1 year ago

norrs commented 1 year ago

This allows the user to configure a threshold on the observer to avoid logging messages to a file which is below a provided threshold.

norrs commented 1 year ago

Use case: We want to send all log levels to our humio endpoint, and only above a provided threshold to file.

Yes, its odd, but this is what we want due to the platforms we are running our software on..

Does this make sense for you @jhannes ?

In the end this ends up probably supporting rest of the configuration provided in AbstractFilteredLogEventObserver:

  observer.foo.filter=WARN,INFO@marker=INTERESTING
  observer.foo.suppressMarkers=HTTP_NOT_MODIFIED
  observer.foo.requireMarker=HTTP
  observer.foo.requireMdc.user=tester1|tester2
  observer.foo.suppressMdc.requestPath=/status

as well.

Should it be added to FileLogEventObserver javadoc as well? Copy/paste? I only included the .threshold one..

norrs commented 1 year ago

And Java CI probably requires updates of some token I suppose:

image

jhannes commented 1 year ago

@norrs Thank you for the contribution

norrs commented 1 year ago

@jhannes Let me know when you can release it.

I'm eagerly waiting to bump to the version so I can close an internal ticket to done and delivered ;-)

jhannes commented 1 year ago

Release 0.4.4 is uploaded to Maven central and will soon be available 🚀

jhannes commented 1 year ago

FileLogEventObserver is quite complex and I'm not sure the functionality included matches all use cases well. It supports patterned file names (so different events can go to different files) and rotation (so that old logs will be compressed and eventually deleted). For efficiency, I'm trying to keep a number of open FileChannels and to avoid recurring errors, I've implemented a circuit breaker.

I'm open to reexamine the functionality and code structure here