Преглед на файлове

feat(日志): 访问日志增加过滤支持

zhouhao преди 2 години
родител
ревизия
8957c8b386

+ 6 - 0
jetlinks-components/logging-component/src/main/java/org/jetlinks/community/logging/access/AccessLoggingTranslator.java

@@ -2,6 +2,7 @@ package org.jetlinks.community.logging.access;
 
 import org.hswebframework.web.logging.events.AccessLoggerAfterEvent;
 import org.jetlinks.community.logging.configuration.LoggingProperties;
+import org.jetlinks.core.utils.TopicUtils;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Component;
@@ -20,6 +21,11 @@ public class AccessLoggingTranslator {
 
     @EventListener
     public void translate(AccessLoggerAfterEvent event) {
+        for (String pathExclude : properties.getAccess().getPathExcludes()) {
+            if (TopicUtils.match(pathExclude, event.getLogger().getUrl())) {
+                return;
+            }
+        }
         eventPublisher.publishEvent(SerializableAccessLog.of(event.getLogger()));
     }