[
https://issues.apache.org/jira/browse/LOG4J2-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13559508#comment-13559508
]
Scott Deboy commented on LOG4J2-155:
------------------------------------
Some comments on the patch:
I needed name/value pairs which can be used to support discovery. The state
representing those name/value pairs is split between the Layout and Manager
implementations used by the Appender. I added an identical method to both
AbstractManager and Layout:
public Map<String, String> getContentFormat()
The Layout and Manager implementations implement these methods and document the
keys and values added to these maps. There is a default empty Map
implementation in AbstractManager to avoid having to change other Manager
implementations.
I've added two parameters to the fileappender and rollingfileappenders:
advertiseViaMulticastDNS and advertiseURI
I've added one parameter to the socketappender: advertiseViaMulticastDNS
I made minor JavaDoc cleanup/typo fixes in a couple of classes.
MulticastDNS requires the 'port' the service is available from, so I add the
'port' as a property in the socket manager, and then remove that property when
doing the zeroconf setup...it was that, or add a getter for the port field in
the socket manager.
The Layouts which support text/plain all expose a 'structured' entry, which is
only true for the RFC5424Layout. They also expose a 'formatType' entry
("RFC5424" in the RFC5424 case, "conversion" in the PatternLayout case, and
"logfilepatternreceiver" in the SyslogLayout case, as well as 'format' and
'dateFormat' fields.
I also added "dtd" and "version" entries to the XMLLayout, which could be
useful in the future.
Mostly this was a lot of plumbing, to get from the pluginattrs over to the
Layouts and the Managers, and making sure the classes with the necessary state
could expose it via the getContentFormat method.
mvn clean install ran fine and passed tests.
Let me know if you have questions.
Scott
> add getFormat to Layout
> -----------------------
>
> Key: LOG4J2-155
> URL: https://issues.apache.org/jira/browse/LOG4J2-155
> Project: Log4j 2
> Issue Type: Improvement
> Reporter: Scott Deboy
> Attachments: log4j2-155-jan22-rev1.patch
>
>
> I was looking at an old rev - getContentType is now exposed - thanks!
> Now if we could add a 'getFormat':
> It would be useful to expose information about a Layout's format.
> If the content type is text/plain, exposing the layout format as a conversion
> pattern would work fine.
> If the content type is text/html or text/xml we could expose something else
> (or null).
> My primary interest is adding the ability to 'discover' the file-based
> logging configurations in order to support them via Chainsaw and multicast
> DNS.
> If all Layouts supporting text/plain content types exposed their format as a
> conversion pattern, and the file-based appenders (optionally) provided the
> ability to advertise their configuration, the files could be remotely tailed
> without the far endpoint even knowing anything about the file configuration.
> For an example, see how multicast appenders are exposed via
> zeroconf/multicast dns in log4j 1.x in activateOptions - something very
> similar could be done with contenttype and format properties in a
> fileappender with a layout.
> if (advertiseViaMulticastDNS) {
> Map properties = new HashMap();
> properties.put("multicastAddress", remoteHost);
> zeroConf = new ZeroConfSupport(ZONE, port, getName(), properties);
> zeroConf.advertise();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]