enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

Support of logging systems other than file #8638

Open rymsha opened 3 years ago

rymsha commented 3 years ago

There is some demand to send XP logs into different logging systems and in different log formats: journalctl, logstash, etc For example: https://discuss.enonic.com/t/log-ouput-in-json/2279

Writing logs to centralized log system instead of file inside container would simplify operations and potentially improve performance:

Simplest way (probably) to implement it is to use https://github.com/logstash/logstash-logback-encoder inside XP core logging system.

tajakobsen commented 2 years ago

I've been using Sentry to aggregate my XP-logs, by using the Logback Sentry Appender.

I even have some library code for it here: https://github.com/ItemConsulting/lib-xp-sentry and here: https://github.com/ItemConsulting/xp-sentry

I can connect ekstra data to the logged statement (Either with MDC or Sentrys own Java-tools).


Problem: Need universal way to hook into all requests

One thing I would like to do is to attach e.g the "User-Agent" header to the log statement for all the user http-requests.

This is easy for "normal content" being served, I can use a filter.

But filters are not run before services or mapped controllers, and so I have to put this "dirty" logging code into each of them.

Can you also look into creating a universal callback somewhere so that I can attach data from the request to all the http-endspoints I have?

That way I could release a Sentry XP-app, that just appends all this useful data to the logs for all http-requests. :slightly_smiling_face: