Enhance the SLF4J's MDC to include OpenNMS information for Collectd and Pollerd

Description

The SLF4J API has a feature called "Mapped Diagnostic Context", or MDC.

OpenNMS is currently using that feature only for decide the target file on which the log messages are going to be stored.

The idea is to add more contexts at run time (on a per-thread basis) to allow a user to redirect all logging related with a particular node, or IP interface, or Service, etc. to a dedicated file. That way it will be easy to figure out problems related with one particular entity on big installations.

Working branch: https://github.com/OpenNMS/opennms/tree/jira/NMS-7752-foundation

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Alejandro Galue October 4, 2015 at 9:31 AM

Yes, it is.

The MDC was updated as I described, but I have no idea about how to actually use these new contexts in conjunction with the current LOG4J2 configuration.

I mean, you cold either use the prefix based config (the current content of log4j2.xml), or the custom based logging using a combination of the fields I've added, but I couldn't found a way to combine both. If you know how to do it without breaking the current functionality, I'd love to hear your ideas.

A little more context, you can create a log directory structure based on nodelabel, foreign-source, etc. and it works. But if you want to do that, and keeping the prefix based separation (i.e. one log per daemon), you cannot (or at least I haven't found a way).

Makes sense ?

Ronny Trommer October 3, 2015 at 9:20 AM

Is this still in progress?

Alejandro Galue June 24, 2015 at 11:28 AM

I haven't found a way to create either mutually exclusive appenders or completely independent appenders in log4j2 reusing its current state.

There is no XSD for the log4j2.xml, so it is hard to understand what's possible or what isn't.

Also, I think we should rework the root appender in order to define the filters inside each appender (assuming this is possible).

Alejandro Galue June 24, 2015 at 11:26 AM

On Branch jira/NMS-7752-foundation, I've added the following properties:

  • Collectd

    • service

    • ipAddress

    • nodeId

    • nodeLabel

    • foreignSource

    • foreignId

    • sysObjectId

  • Pollerd

    • service

    • ipAddress

    • nodeId

    • nodeLabel

Details

Assignee

Reporter

Labels

Components

Priority

PagerDuty

Created June 22, 2015 at 2:38 PM
Updated November 16, 2023 at 9:13 AM