- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一整天都在做这个,但在尝试了这么多组合之后还是没能正常工作。归根结底,我正在寻找从 Karaf 获取 JSON 日志记录的明确步骤列表。我什至浏览了 Maven Karaf 插件源代码,试图解决这个问题,尽管我可能看得不够远。
我正在使用 Karaf 4.2.6。我正在尝试使用版本 4.2.6 的 karaf-maven-plugin 构建 Karaf 部署。
如果我将各种 appender 的 layout.type
更改为 JsonLayout
,我会得到一个堆栈跟踪,说它无法加载 JSON 布局,因为我缺少一个类。 java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider
.
我查看了 jar org.ops4j.pax.logging/pax-logging-log4j2/1.10.2
,发现我需要 3 个 Jackson jar,Core v2.8.7,Annotations v2.8.0,和数据绑定(bind) 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
包含具有适当启动级别的 Jackson jar 。
我在 Kubernetes 中运行我的容器,并希望 Kubernetes 中的标准日志收集能够正常工作。我在日志收集器上使用一个额外的插件来至少将一些东西分离成 JSON 格式,但它很容易出错,我宁愿只从 JSON 格式的日志开始,而不是稍后在下游处理,这样我就可以分离组件日志,例如执行操作的人,在日志记录时。
我在 Stack Overflow 上进行了搜索,在 Google 上进行了搜索,并找到了提示,但没有找到解决方案的明确步骤。我知道这里没有明确的文件列表,但是,正如我所说,我经历了很多组合。任何帮助将非常感激。我还将在 Karaf 用户组上发帖。
最佳答案
好的,几天后,我想出了所有需要做的事情。感谢@GrzegorzGrzybek 的帮助。
我需要以下几行
mvn\:org.ops4j.pax.logging/pax-logging-log4j2-extra/1.11.4 = 8
mvn\:com.fasterxml.jackson.core/jackson-core/2.9.10 = 8
mvn\:com.fasterxml.jackson.core/jackson-annotations/2.9.10 = 8
mvn\:com.fasterxml.jackson.core/jackson-databind/2.9.10 = 8
添加到我的 etc/startup.properties
.如果我只是编辑文件以添加它们,并确保我在 system
中有这些文件存储库,它不会工作。不知道,在 etc
的其他地方没有输入一些条目配置,因此容器无法启动,或者某些功能集在 wrap
之前启动处理程序已安装,因此整个容器将停止运行。
我尝试了很多组合,但最终找到了如何将东西放入 etc/startup.properties
中.我将我想要的 bundle 放入它们自己的功能中,并具有我希望它们拥有的起始级别。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="myapp-common-container-feature">
<feature name="com.me.myapp.logging.provider" version="0.12.0" description="MyApp Logging Provider">
<bundle start-level="8">mvn:com.fasterxml.jackson.core/jackson-annotations/2.9.10</bundle>
<bundle start-level="8">mvn:com.fasterxml.jackson.core/jackson-core/2.9.10</bundle>
<bundle start-level="8">mvn:com.fasterxml.jackson.core/jackson-databind/2.9.10</bundle>
<bundle start-level="8">mvn:org.ops4j.pax.logging/pax-logging-log4j2-extra/1.11.4</bundle>
</feature>
</features>
注意 start-level
属性。
然后,在我的程序集 POM 中,我放置了以下依赖项:
<dependency>
<groupId>com.me.myapp</groupId>
<artifactId>myapp-common-container-feature</artifactId>
<version>0.12.0</version>
<classifier>features</classifier>
<type>xml</type>
<scope>compile</scope>
</dependency>
这里重要的一行是<scope>compile</scope>
. compile
中的功能范围将放在 startup.properties
中如果放在 <startupFeatures />
在 Karaf Maven 插件的配置中。
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<configuration>
<startupFeatures>
<feature>com.me.myapp.logging.provider/0.12.0</feature>
</startupFeatures>
现在容器以 JSON 日志记录启动。
关于json - 无法让 Karaf 4.2.6 使用带有 JsonLayout 的 log4j2 记录布局类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61493642/
在C语言中,当有变量(假设都是int)i小于j时,我们可以用等式 i^=j^=i^=j 交换两个变量的值。例如,令int i = 3,j = 5;在计算 i^=j^=i^=j 之后,我有 i = 5,
我为以下问题编写了以下代码: 给定一个由 N 个正整数组成的序列 A,编写一个程序来查找满足 i > A[j]A[i](A[i] 的 A[j] 次方 > A[j] 的 A[i] 次方)。 我的代码通过
这个表达式是从左到右解析的吗?我试图解释解析的结果,但最后的结果是错误的。 int j=10, k=10; j+=j-=j*=j; //j=j+(j-=j*=j)=j+(j-j*j) k+=k*=
给定一个整数数组 A ,我试图找出在给定位置 j ,A[j] 从每个 i=0 到 i=j 在 A 中出现了多少次。我设计了一个如下所示的解决方案 map CF[400005]; for(int i=0
你能帮我算法吗: 给定 2 个相同大小的数组 a[]和 b[]具有大于或等于 1 的整数。 查找不相等的索引 i和 j ( i != j ) 使得值 -max(a[i]*b[i] + a[i] * b
每次用J的M.副词,性能显着下降。因为我怀疑艾弗森和许比我聪明得多,我一定是做错了什么。 考虑 Collatz conjecture .这里似乎有各种各样的内存机会,但不管我放在哪里M. ,性能太差了
假设一个包含各种类型的盒装矩阵: matrix =: ('abc';'defgh';23),:('foo';'bar';45) matrix +---+-----+--+|abc|defgh|23|+
是否有可能对于两个正整数 i 和 j,(-i)/j 不等于 -(i/j)?我不知道这是否可能......我认为这将是关于位的东西,或者 char 类型的溢出或其他东西,但我找不到它。有什么想法吗? 最
假设两个不同大小的数组: N0 =: i. 50 N1 =: i. 500 应该有一种方法可以获得唯一的对,只需将两者结合起来即可。我发现的“最简单”是: ]$R =: |:,"2 |: (,.N0)
我是 J 的新用户,我只是想知道 J 包中是否实现了三次样条插值方法? 最佳答案 我自己不熟悉,但是我确实安装了所有的包,所以 $ rg -l -i spline /usr/share/j/9.02
在 Q/kdb 中,您可以使用 ': 轻松修改动词,它代表每个优先级。它会将动词应用于一个元素及其之前的邻居。例如 =': 检查值对是否相等。在 J 中,您可以轻松折叠 /\ 但它是累积的,是否有成对
嗨,我有一个 4x4 双矩阵 A 1+2i 2-1i -3-2i -1+4i 3-1i -3+2i 1-3i -1-3i 4+3i 3+5i 1-2i -1-4i
刚刚发现 J 语言,我输入: 1+^o.*0j1 I expected the answer to be 0 ,但我得到了 0j1.22465e_16。虽然这非常接近于 0,但我想知道为什么 J 应该
这个问题在这里已经有了答案: With arrays, why is it the case that a[5] == 5[a]? (20 个答案) 关闭 3 年前。 我正在阅读“C++ 编程语言”
当第一行是 1, 1/2 , 1/3 ....这是支持该问题的图像。 是否存在比朴素的 O(n^2) 方法更有效的方法? 我在研究伯努利数时遇到了这个问题,然后在研究“Akiyama-Tanigawa
我写了一段Java代码,它在无限循环中运行。 下面是代码: public class TestProgram { public static void main(String[] args){
for (int i = n; i > 0; i /= 2) { for (int j = 0; j 0; i /= 2) 的第一个循环结果 O(log N) . 第二个循环for (int
如问题中所述,需要找到数组中 (i,j) 对的总数,使得 (1) **ia[j]** 其中 i 和 j 是数组的索引。没有空间限制。 我的问题是 1) Is there any approach w
for l in range(1,len(S)-1): for i in range(1,len(S)-l): j=i+l for X in N:
第二个for循环的复杂度是多少?会是n-i吗?根据我的理解,第一个 for 循环将执行 n 次,但第二个 for 循环中的索引设置为 i。 //where n is the number elemen
我是一名优秀的程序员,十分优秀!