Details
-
Wish
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
2.0-beta9
-
None
-
None
-
Java 1.7, Linux
Description
I want this callbacks to add some custom info at the top of each logfile, like the version string of my application, the application uptime and the system uptime. And even writing some »bye, bye / eof« to the bottom of the just closed logfile would also be fine.
See also:
LOG4J2-486- http://stackoverflow.com/questions/20819376/log4j2-rollingfile-appender-add-custom-info-at-the-start-of-each-logfile
Currently I need to extend DefaultRolloverStrategy and wrap around RolloverDescription and appender.rolling.helper.Action to place my code
(and therefore I also have to copy some factory code of DefaultRolloverStrategy to support all config parameters etc.). Ok, this approach currently works but it needs ~150 lines of code and is maintenance-unfriendly eg. if DefaultRolloverStrategy gets more config parameters in future versions.
The callbacks should provide at least the filename of the related logfile.
An access to the configured Layout of the related appender would also helpful, so that the custom info could be correctly formatted (e.g. incl. timestamp or matching for xml etc.).
I think there sould be 2 callbacks
- 1st one for after all outstanding writes to the old logfile has been done (so thet I could add some stuff to the end of the old file), but before things like compressing are performed
- 2nd one for to write my stuff to the top of the new logfile
Ok, there must be take care of Layout.getHeader/Footer() (which is used by e.g. XMLLayout) considering if the callbacks should be called e.g. "inside or outside of the xml root tags".
If I want to add my custom info as a kind of LogEvents, then the callbacks should be called before writing the Layout.getFooter() and after writing Layout.getHeader() to the file.
But if someone want to add custom info outside of the xml root tags (e.g. someone might calculate a checksum over the logfile and write that to the very last line of the file) then the callbacks must be called outside header/footer.
For my current needs, I require the callbacks inside of header/footer (although it not really matters for me while I currently only using PatternLayout).
Bug finally that looks that we need callbacks for both cases.
Attachments
Issue Links
- is related to
-
LOG4J2-486 RollingFile Appender - add custom info at the start of each logfile
- Closed
- relates to
-
LOG4J2-496 Allow Layout header and footer to be configured in files and to contain properties.
- Closed