我一整天都在做这件事,但在尝试了这么多组合后却没有让它发挥作用。归根结底,我正在寻找从 Karaf 获取 JSON 日志记录的明确步骤列表。我什至浏览了 Maven Karaf 插件源代码,试图解决这个问题,尽管也许我看的还不够远。
我正在使用 Karaf 4.2.6。我正在尝试使用 karaf-maven-plugin 版本 4.2.6 构建 Karaf 部署。
如果我改变我的layout.type
对于各种附加程序JsonLayout
,我得到一个堆栈跟踪,说它无法加载 JSON 布局,因为我缺少一个类。java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider
.
我看了看罐子org.ops4j.pax.logging/pax-logging-log4j2/1.10.2
发现我需要 3 个 Jackson jar,Core v2.8.7、Annotations v2.8.0 和 Databind v2.8.7。
我一直在尝试将这些文件放入etc/startup.properties
起始级别为 5 或起始级别为 8,以便他们准备好org.ops4j.pax.logging/pax-logging-log4j2/1.10.2
当它开始时。我确定他们在system
文件夹放在正确的位置。大多数时候,如果我确实让他们进入etc/startup.properties
,它们的起始级别为 30。我将它们放置在具有正确起始级别的功能中,但它们要么在使用过任何内容后才启动startup.properties
或者只是从未出现。我尝试了很多可能的组合,startupBundles
, startupFeatures
, bootFeatures
,但没有任何东西进入startup.properties
。我无法弄清楚内容如何startup.properties
生成了。有时,我想要的应用程序功能甚至无法启动,因为如果我只是将对这些 jar 的引用放置在设置日志记录时,有关配置的某些内容会被阻止startup.properties
, 例如
mvn\:com.fasterxml.jackson.core/jackson-core/2.8.7 = 5
下面是我的 pom.xml,其中注释掉了之前尝试的一些内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<my_version>0.0.0</my_version>
<myapp_common_version>0.0.0</myapp_common_version>
</properties>
<groupId>com.me.myapp</groupId>
<artifactId>myapp-karaf</artifactId>
<version>${my_version}</version>
<packaging>karaf-assembly</packaging>
<name>myapp-karaf</name>
<description>myapp-karaf details</description>
<repositories>
<!-- Apache ServiceMix repository (for region) -->
<repository>
<id>apache.servicemix.m2</id>
<name>Apache ServiceMix M2 repository</name>
<url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- OPS4J SNAPSHOT repository -->
<repository>
<id>ops4j.sonatype.snapshots.deploy</id>
<name>OPS4J snapshot repository</name>
<url>https://oss.sonatype.org/content/repositories/ops4j-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!-- Apache SNAPSHOT -->
<repository>
<id>apache.snapshots.deploy</id>
<name>Apache snapshot repository</name>
<url>https://repository.apache.org/content/groups/snapshots-group</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>framework</artifactId>
<version>4.2.6</version>
<type>kar</type>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>standard</artifactId>
<version>4.2.6</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>spring</artifactId>
<version>4.2.6</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>enterprise</artifactId>
<version>4.2.6</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.me.myapp</groupId>
<artifactId>myapp-common-feature</artifactId>
<version>${myapp_common_version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.me.myapp</groupId>
<artifactId>myapp-feature</artifactId>
<!-- Annoyingly this cannot come from an environment variable -->
<version>${my_version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${env.MYAPP_SOURCE_HOME}/myapp-common/server/karaf/assembly</directory>
<filtering>false</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>4.2.6</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>process-resources</id>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<configuration>
<startupBundles> <!--
<bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.8.0</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.8.7</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.8.7</bundle> -->
</startupBundles>
<installedFeatures>
</installedFeatures>
<startupFeatures>
<feature>com.me.myapp/${my_version}</feature>
</startupFeatures>
<bootFeatures>
<feature>com.me.myapp.logging.provider/${myapp_common_version}</feature>
<!-- standard distribution -->
<!-- <feature>standard</feature> -->
<!-- minimal distribution -->
<!--<feature>minimal</feature>-->
<feature>jaas</feature>
<feature>shell</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>bundle</feature>
<feature>config</feature>
<feature>deployer</feature>
<feature>diagnostic</feature>
<feature>instance</feature>
<feature>kar</feature>
<feature>wrap</feature>
<feature>log</feature>
<feature>package</feature>
<feature>service</feature>
<feature>system</feature>
</bootFeatures>
<javase>1.8</javase>
</configuration>
</plugin>
</plugins>
</build>
</project>
com.me.myapp.logging.provider
包含具有正确启动级别的杰克逊罐子。
我正在 Kubernetes 中运行容器,并希望 Kubernetes 中的标准日志收集能够正常工作。我在日志收集器上使用额外的插件,至少将内容分离为 JSON 格式,但它很容易出错,我宁愿从 JSON 格式的日志开始,而不是稍后在下游处理,这样我就可以分离日志的组件记录,例如记录时执行操作的人。
我在 Stack Overflow 上进行了搜索,在 Google 上进行了搜索,并找到了提示,但没有明确的步骤来提供解决方案。我意识到这里没有明确的文件列表,但是,正如我所说,我经历了很多组合。任何帮助将非常感激。我还将在 Karaf 用户组上发帖。