Home > Software design >  Generic Entity for print logs
Generic Entity for print logs

Time:05-25

I have a need in a project and I don't really know how to do the architecture (springboot, with Kubernetes deployment).

I need to have a microservice only for logs, that is, that paints everything that I send to it in the log.

At first I wanted to send it (log[debug, info, error], client number, entity), but that entity must be generic and I would like to paint a ToString of said entity in the Log4J line.

Any idea how to expose a Rest that has a generic entity that I can then paint? I comment on the generic entity because some entities have 40 fields, others 20... and each one with different names.

Thank you very much to all.

CodePudding user response:

You can't know the toString method of your POJO if you do not import them in your logging project so, what I would recommend is to create a LogMessage POJO that you use in your logging endpoint and have the client convert the log message to this when sending.

CodePudding user response:

I understand what you're saying but it's not really what I'm looking for. I have several different systems that are going to call the log microservice. And not on all systems I can easily get the ToString of the object.

Couldn't you send a generic Object to java and read it from the microservice to paint its content? Is there no alternative?

  • Related