[ 
https://issues.apache.org/jira/browse/LOG4J2-1323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15202090#comment-15202090
 ] 

Andrew Bernhagen commented on LOG4J2-1323:
------------------------------------------

Hey Ralph, thanks for the quick response.

I need to force a very specific JSON format that isn't conducive to the 
integrated JsonLayout class.  Additionally, we want to enforce standard values 
for the log file name, rollover policies, etc.  Most of these fields are pulled 
via configuration obtained at runtime, which as been a challenge working around 
some the static methods that are currently required.  I'm still working on my 
interim implementation, but some examples of what I've been doing to get what I 
need:

-I was able to extend RollingFileManager and change the fileName used to 
control the actual log file name.  As part of this extension, I had to copy all 
the private static classes from RollingFileManager (AsyncAction, FactoryData, 
and RollingFileManagerFactory).
-To create my own RolloverStrategy, I can't reuse the DefaultRolloverStrategy 
as it contains a number of private final fields with no getters.  These fields 
are used in the public rollover() method, which I could overwrite, but I can't 
change small pieces of it as I can only call super or nothing at all.
-I looked into implementing my own PatternProcessor to force the rollover name 
to be something dynamically determined at runtime, but the methods I need to 
override (all overloaded formatFileName()) are final preventing any override or 
change of implementation.
-My custom appenders needed to override the AbstractOutputStreamAppender 
instead of RollingFileAppender because the latter is final, even though I want 
almost all the same behavior in RollingFileAppender and just want to enforce my 
particular values where appropriate.

I believe I can get through all my challenges if some classes were opened up 
further to extension.  Thanks!

> Remove Final Declarations on Many Classes/Methods
> -------------------------------------------------
>
>                 Key: LOG4J2-1323
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1323
>             Project: Log4j 2
>          Issue Type: Wish
>          Components: API, Appenders, Pattern Converters
>    Affects Versions: 2.5
>            Reporter: Andrew Bernhagen
>              Labels: architecture, easyfix, newbie, patch
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Within my organization, I've had to develop a custom appender that 
> automatically configures certain properties and a specific layout to tie into 
> other initiatives we have tied to logging.  Log4j2 made this much more 
> difficult than Log4j1 due to the use of final on many classes (e.g. the 
> appender implementations) and methods (all pattern layout methods).  This has 
> made extension overly difficult and filled with a lot of copy and paste that 
> I'd rather not have.  Is it possible that these could be removed to make it 
> easier to extend the existing implementations?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to