0

I have a need to centralize the 2 logs file of my application deployed in 2 different server in prod environment.

If possible I would like to use logback and not logstash cause we already support it in the java app.

I did some research but I found lot of solutions for generate more log files but not to unite the ones I already have.

What I would like to achieve is the merge of this 2 logs file either into a new log file or in a database because then I need to send the union of this 2 logs through a REST Service.

Could you help me? Thanks

user2298581
  • 532
  • 3
  • 11
  • 37
  • Maybe use a service that does it for you like Elastic Search with Kibana, or DataDog... – Pam Stums Jul 06 '22 at 09:56
  • 1
    Another option is to use the same log on both servers using Network Log or it might be called Socket Log. In LogBack that is called ServerSocketAppender: https://logback.qos.ch/manual/appenders.html#serverSocketAppender – Pam Stums Jul 06 '22 at 09:59
  • Regarding the serverSocketAppender I'm trying to understand how it works. In the doc is written: "start SimpleSocketServer with the following command: java ch.qos.logback.classic.net.SimpleSocketServer 6000 \ src/main/java/chapters/appenders/socket/server1.xml" If I run it I get: "Error: Could not find or load main class ch.qos.logback.classic.net.SimpleSocketServer" I don't understand the command... – user2298581 Jul 07 '22 at 15:08
  • ch.qos.logback.classic.net.SimpleSocketServer what should it be ? a URL ? or should I download the logback repository and find that class? cause it's seem to me that my bash can't find it – user2298581 Jul 07 '22 at 15:11
  • About the class not found, it means you need to set the classpath like this: java -cp LOGBACK.jar ch.qos.logback.classic.net.Simple... just need to know what the path+filename of the logback jar. See here how to run java with classpath in this answer: https://stackoverflow.com/questions/5474666/how-to-run-a-class-from-jar-which-is-not-the-main-class-in-its-manifest-file – Pam Stums Jul 08 '22 at 10:58
  • Another option - but not sure it fits all cases... is the write a small service that its function is only to write logs. and any server that wants to write a log simply calls this "microservice" using REST. – Pam Stums Jul 08 '22 at 11:01

0 Answers0