Fish Tagging
Fish tagging in Martini is a technique used to include tags within logs for tracking and identification purposes. These tags provide valuable information such as the time and location of events, movement logging, operating environment details, authenticated usernames, and more.
To configure fish tagging in Martini, follow these steps:
Supported Fish Tags
Configure the following tags in your log4j2.properties
file 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 |
|
Ensure the tag format is added to log4j2.properties
as $martini:<thetagname>
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 tracker.xml
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 conf/properties/package.properties
file to apply fish tagging specifically to that package.