Skip to content

Fish Tagging in Martini

Fish tagging in Martini uses tags within logs for tracking and identification, capturing details like event time, location, movement, and user authentication. Built on Log4j2's pattern layout, it logs data from user authentication to HTTP requests and service execution. For configuration details, refer to the Apache Log4j2 Pattern Layout documentation.

To configure fish tagging in Martini, follow these steps:

Supported Fish Tags

Configure the following tags in your log4j2.properties file located in <martini-home>/conf/overrides/ to include relevant information in your logs:

  • [ %X{user} ]: Authenticated user
  • [ %X{http-method} ]: HTTP method
  • [ %X{ip} ]: IP address
  • [ %X{uri} ]: URI of the invoked REST API

Common Fish Tags

Common operating environment tags like host, instance, region, and stack can also be included in logs. To add common fish tags, set the desired tag names and values in the logging.tags property in your application properties file. For example:

1
logging.tags.region=us-east-1

Ensure the tag format is added to log4j2.properties as $martini:<tag-name> to be utilized.

Logger Key Fish Tagging

Dynamic tag values can be provided using Martini's Logger.addFishTag method. Set the variable $service:<your-tag-name-here> in the log4j2.properties and use the tag name in Logger.addFishTag, assigning it any desired value.

Service Fish Tags

Martini supports the following tags related to service execution:

  • [ %X{service-name} ]
  • [ %X{service-type} ]

These tags can enhance the content of logs.

Endpoint Fish Tags

When tracking invoked endpoints, the following tags can be utilized:

  • [ %X{endpoint-name} ]
  • [ %X{endpoint-type} ]
  • [ %X{document-type} ]
  • [ %X{package-name} ]
  • [ %X{tracker-id} ]
  • [ %X{user} ]

Package MVC Fish Tags

To log information related to packages, enable trackers.xml, which is also located in <martini-home>/conf/overrides and include the following tags in your logs:

  • [ %X{tracker-id} ]
  • [ %X{package-name} ]
  • [ %X{service-name} ]
  • [ %X{service-type} ]

Package Level Fish Tag

Martini supports fish tagging at the package level. Set the log4j.package.pattern property in the package's /<martini-home>/packages/<package-name>/conf/properties/package.properties file to apply fish tagging specifically to that package.