The spring-boot application I'm working on uses Logback's classic DBAppender
to add log entries to a (Postgres) database.
I would like to access these records, preferably using a JpaRepository
for LoggingEvent
.
I've tried creating my own LoggingEvent
entity matching the schema of Logback's own LoggingEvent
class, and making that a Jpa @Entity
. However, using the logging_event
table for my LoggingEvent
class seems to in some way inhibit Logback from using the table itself. Some log entries are appended, but others (e.g all logs from the spring RestController
s) are not.
What is the most spring-congruent way of accessing these entries without interfering with Logback's database appender?
logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<property resource="config.properties"/>
<property resource="application.properties"/>
<property name="LOGS" value="./logs"/>
<!--APPEND LOG TO DATABASE-->
<appender name="Database" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
<driverClass>org.postgresql.Driver</driverClass>
<url>jdbc:postgresql://localhost:5432/databasename</url>
<user>postgres</user>
<password>postgres</password>
</connectionSource>
</appender>
<root level="info">
<appender-ref ref="Database"/>
</root>
</configuration>