我有一个带有Spring框架和Logback的Maven项目。我正在尝试在logstash上设置spring活动配置文件。这是我所做的一些尝试:
<springProperty scope="context" name="ACTIVE_PROFILE" source="spring.profiles.active" />
<appender name="STASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>x.x.x.x:yyyy</destination>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<mdc /> <!-- MDC variables on the Thread will be written as JSON fields -->
<context /> <!-- Outputs entries from logback's context -->
<version /> <!-- Logstash json format version, the @version field in the output -->
<logLevel />
<loggerName />
<pattern>
<pattern>
{
"APP": "XX",
"PROFILE": "${ACTIVE_PROFILE}"
}
</pattern>
</pattern>
<threadName />
<message />
<logstashMarkers /> <!-- Useful so we can add extra information for specific log lines as Markers -->
<arguments /> <!-- or through StructuredArguments -->
<stackTrace />
</providers>
</encoder>
</appender>
和
<appender name="STASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>x.x.x.x:yyyy</destination>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<mdc /> <!-- MDC variables on the Thread will be written as JSON fields -->
<context /> <!-- Outputs entries from logback's context -->
<version /> <!-- Logstash json format version, the @version field in the output -->
<logLevel />
<loggerName />
<pattern>
<pattern>
{
"APP": "XX",
"PROFILE": "${spring.profiles.active}"
}
</pattern>
</pattern>
<threadName />
<message />
<logstashMarkers /> <!-- Useful so we can add extra information for specific log lines as Markers -->
<arguments /> <!-- or through StructuredArguments -->
<stackTrace />
</providers>
</encoder>
</appender>
我的尝试都没有成功。有人知道我该如何在logback的logstash中设置spring profile
?