-
Notifications
You must be signed in to change notification settings - Fork 11
Monitor Access
VolkerHartmann edited this page Feb 8, 2022
·
2 revisions
To monitor access of REST-API of the MetaStore you have the possibility to write all accesses to /api/v1 to an Logging appender.
To enable Metastore to find the configuration file (logback-spring.xml) you should place it next to your jar-file. Then you may start Metastore with the following command:
>java -Dloader.path=. -jar metastore2-x.x.x.jar
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOGS" value="./logs/access" />
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%gray(%d{YYYY-MM-dd HH:mm:ss.SSS}) %green(%highlight(%5p)) - %gray([%10thread]) %cyan(%42logger{42}) : %msg%n</pattern>
</layout>
</appender>
<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS}/logFile.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{YYYY-MM-dd}, %m%n</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 7 days' worth of history -->
<maxHistory>7</maxHistory>
</rollingPolicy>
</appender>
<!-- LOG everything at INFO level -->
<root level="info">
<appender-ref ref="Console" />
</root>
<!-- LOG "com.baeldung*" at TRACE level -->
<logger name="edu.kit.datamanager.metastore2.filter" level="trace" additivity="false">
<appender-ref ref="RollingFile" />
</logger>
</configuration>
This may allow you to analyze logs and write directly to another (monitoring) service. https://www.baeldung.com/custom-logback-appender