bluedenim/log4j-s3-search

Support Property Substitution on Path/Prefix.

Closed this issue · 4 comments

Hi,

We are moving some of our architecture to the cloud and are hoping to use this adapter to do cloud storage agnostic log4j2 logging. This is the best alternative I've found so far with out of the box support for all the major cloud providers + more - pretty awesome!

This is our current logging configuration. As you can see, we make use of context variables to dynamically set the file path. The readme makes it seem like this isn't possible today - is that correct?

If not, I'm very happy to help implement this. Would love some guidance on how to go about doing this!

Thanks!

Hello,

There is limited support of "path" customization currently done by PattternedPathAdjuster.

So one way to inject your own logic is to replace the current code (e.g. https://github.com/bluedenim/log4j-s3-search/blob/master/appender-log4j2/src/main/java/com/van/logging/log4j2/Log4j2AppenderBuilder.java#L249 for the Log4j2 appender builder) that hard-coded PatternedPathAdjuster with new code that will instead check for a configuration property (probably a FQCN indicating your own implementation of IStorageDestinationAdjuster). This is similar to the approach taken for an Elasticsearch publisher here.

I'm not sure what context information you will need to pass in from the config to your implementation to actually customize the "path." Depending on that, you may need to add more properties to the appenders.

Let me know where I can elaborate if you have questions.

Van

Thanks @bluedenim ! Looking into this now.

Would you be open to me merging my changes back into this repo? I imagine others might find this useful as well!

Sure! I will ask that whatever you're planning, make sure it works across:

  • log4j and log4j2
  • aws, azure, and gcs

Making sure something works across these (6 total) settings can be tedious.

I realised that this is something Log4j2 supports out of the box so we don't actually need to do anymore. We are happily using this plugin - check it out!