Reputation: 31
we have an application with several RESTful services implemented. All these services are bundled into one big war file. Due to infrastructure constraints, we cannot go for microservice design. Since this is one big app with multiple REST APIs, all the messages are written to the same application log and obviously it is difficult to trace the flow of a particular transaction.
This app is running on JBoss EAP 7.1. The logging profile is configured in the stand-alone xml. The logging profile name is mentioned in the manifest file.
My question is, is it possible to maintain multiple logging profiles like one profile for one API? The idea is to have one log for one API so that tracing flow is events for a particular transaction would be easy. If this is not feasible, are there any other ways to implement this?
Upvotes: 0
Views: 240
Reputation: 17825
No, this is not possible. Logging profiles are isolated per class loader. Since these API's are all in the same application, it's the same class loader.
That said, you could use different logger names for each API. For example if you did something like;
Logger.getLogger("org.example.api1");
Logger.getLogger("org.example.api2");
Then you could send them to different handlers. In CLI, assuming no logging profile here, it would look something like:
/subsystem=logging/file-handler=api1:add(file={relative-to=jboss.server.log.dir, path=api1.log}, named-formatter=PATTERN, append=false)
/subsystem=logging/logger=org.example.api1:add(use-parent-handlers=false, level=INFO, handlers=[api1])
/subsystem=logging/file-handler=api2:add(file={relative-to=jboss.server.log.dir, path=api2.log}, named-formatter=PATTERN, append=false)
/subsystem=logging/logger=org.example.api2:add(use-parent-handlers=false, level=INFO, handlers=[api2])
Upvotes: 0