Hello again, Well, I think that both these options are not good for me. First I DO want to keep a separate track for each logger so the sequence number is no good.
Second, using the a custom pattern or a lookup plugin both seem too intrusive to me. What if an appender already has a pattern or a lookup defined?. Unless someone comes up with a better I think I'll stick with my rewrite appender and just notify the user they cannot define a filter on the appender if they want the metrics to reflect reality. Thanks a lot for the help, Guy On Sun, Dec 11, 2016 at 2:11 PM, Guy Marom <marom....@gmail.com> wrote: > Thanks, I'll take a look at this suggestion! > > On Sun, Dec 11, 2016 at 1:56 PM, Remko Popma <remko.po...@gmail.com> > wrote: > >> One option is the SequenceNumber >> <https://github.com/apache/logging-log4j2/blob/76d78fe9a4adecebd9805d051a1606b2ac70ccd0/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/SequenceNumberPatternConverter.java> >> pattern converter %sn in PatternLayout >> <https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout>. >> This uses a static counter, so if you need to keep separate track of >> multiple appenders this may not be useful. >> What you could do then is create a custom pattern converter plugin or >> lookup plugin. >> >> On Sun, Dec 11, 2016 at 8:40 PM, Guy Marom <marom....@gmail.com> wrote: >> >>> Hello everyone, >>> I want to count all the logging events into our metrics system >>> (Prometheus). Our devs are using this to create alerts for Error/Fatal/Warn >>> events. >>> >>> I gave up using filters because they catch all the events and not just >>> the ones that are actually written to the logger. >>> >>> My current idea is to use a rewrite appender with my own rewrite policy >>> which will just increment the relevant counter and not modify the event. >>> The problem with this approach is again the filters, if an appender has >>> a filter defined then I will count events that end up discarded. >>> >>> Is there some post-logging hook I can use? An event maybe? Any help will >>> be much appreciated... >>> Thanks, >>> Guy Marom >>> >> >> >