Logging to database

I am trying to log information to database instead of files.

The logging config file org.ops4j.pax.logging.cfg has only RollingRandomAccessFile appender configured. Can we configure a database appender so that I can log information from the program to database (like mysql)?

Or is there any other simpler way to do this so that I can make my program to log information to database?

I haven’t used any of these 2 options, so you should check various log4j2 info in the internet:

  1. Graylog: https://github.com/mp911de/logstash-gelf/
  2. JDBC: https://www.boraji.com/log4j-2-jdbcappender-example

Info: https://logging.apache.org/log4j/2.x/manual/appenders.html (many options)

In case of Graylog see Logging to graylog.

Regarding log4j2 you are limited to the appenders bundeled by ESH.