upgrade log4j2 version and fix log4j2.xml provided sample (#3721)
* upgrade log4j2 version and fix log4j2.xml provided sample, add disruptor if users wants to use async logging Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
03baa6bc9b
commit
8f4cdf1c83
|
@ -23,5 +23,6 @@ Log4j is released under the Apache 2.0 license.
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
[ini]
|
[ini]
|
||||||
log4j2.version?=2.11.1
|
log4j2.version?=2.11.2
|
||||||
|
disruptor.version=3.4.2
|
||||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/log4j2/
|
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/log4j2/
|
||||||
|
|
|
@ -19,6 +19,7 @@ log4j2-impl
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
maven://org.apache.logging.log4j/log4j-core/${log4j2.version}|lib/log4j2/log4j-core-${log4j2.version}.jar
|
maven://org.apache.logging.log4j/log4j-core/${log4j2.version}|lib/log4j2/log4j-core-${log4j2.version}.jar
|
||||||
|
maven://com.lmax/disruptor/${disruptor.version}|lib/log4j2/disruptor-${disruptor.version}.jar
|
||||||
basehome:modules/log4j2-impl
|
basehome:modules/log4j2-impl
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Configuration status="warn" name="Jetty" >
|
<Configuration status="warn" name="Jetty" >
|
||||||
|
|
||||||
<Appenders>
|
<properties>
|
||||||
</Appenders>
|
<property name="logging.dir">${sys:jetty.logging.dir:-logs}</property>
|
||||||
<Loggers>
|
</properties>
|
||||||
<Root level="error">
|
|
||||||
<AppenderRef ref="STDOUT"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
|
||||||
|
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="console" target="SYSTEM_ERR">
|
<Console name="console" target="SYSTEM_ERR">
|
||||||
|
@ -16,24 +12,33 @@
|
||||||
</PatternLayout>
|
</PatternLayout>
|
||||||
</Console>
|
</Console>
|
||||||
|
|
||||||
<!--
|
|
||||||
<RollingFile name="file"
|
<RollingRandomAccessFile name="file"
|
||||||
fileName="${jetty.logging.dir}/jetty.log"
|
fileName="${logging.dir}/jetty.log"
|
||||||
filePattern="${jetty.logging.dir}/jetty-%d{MM-dd-yyyy}.log.gz"
|
filePattern="${logging.dir}/jetty-%d{MM-dd-yyyy}.log.gz"
|
||||||
ignoreExceptions="false">
|
ignoreExceptions="false">
|
||||||
<PatternLayout>
|
<PatternLayout>
|
||||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</Pattern>
|
<Pattern>%d [%t] %-5p %c %x - %m%n</Pattern>
|
||||||
</PatternLayout>
|
</PatternLayout>
|
||||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
|
||||||
<DefaultRolloverStrategy max="10"/>
|
<Policies>
|
||||||
</RollingFile>
|
<TimeBasedTriggeringPolicy />
|
||||||
-->
|
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||||
|
</Policies>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
</Appenders>
|
</Appenders>
|
||||||
|
|
||||||
<Loggers>
|
<Loggers>
|
||||||
<Root level="info">
|
<Root level="info">
|
||||||
<AppenderRef ref="console"/>
|
<AppenderRef ref="console"/>
|
||||||
</Root>
|
</Root>
|
||||||
|
<!--
|
||||||
|
To have all logger async
|
||||||
|
<AsyncRoot level="info">
|
||||||
|
<AppenderRef ref="file"/>
|
||||||
|
</AsyncRoot>
|
||||||
|
-->
|
||||||
</Loggers>
|
</Loggers>
|
||||||
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
3
pom.xml
3
pom.xml
|
@ -20,7 +20,8 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<build-support.version>1.4</build-support.version>
|
<build-support.version>1.4</build-support.version>
|
||||||
<slf4j.version>1.7.25</slf4j.version>
|
<slf4j.version>1.7.25</slf4j.version>
|
||||||
<log4j2.version>2.11.1</log4j2.version>
|
<log4j2.version>2.11.2</log4j2.version>
|
||||||
|
<disruptor.version>3.4.2</disruptor.version>
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<jetty-test-policy.version>1.2</jetty-test-policy.version>
|
<jetty-test-policy.version>1.2</jetty-test-policy.version>
|
||||||
<alpn.api.version>1.1.3.v20160715</alpn.api.version>
|
<alpn.api.version>1.1.3.v20160715</alpn.api.version>
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.jetty.http2.client.HTTP2Client;
|
||||||
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
|
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
|
||||||
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
|
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
|
||||||
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
||||||
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||||
|
@ -265,4 +266,47 @@ public class DistributionTests extends AbstractDistributionTest
|
||||||
Files.deleteIfExists(sockFile);
|
Files.deleteIfExists(sockFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLog4j2ModuleWithSimpleWebAppWithJSP() throws Exception
|
||||||
|
{
|
||||||
|
Path jettyBase = Files.createTempDirectory( "jetty_base");
|
||||||
|
String jettyVersion = System.getProperty("jettyVersion");
|
||||||
|
DistributionTester distribution = DistributionTester.Builder.newInstance()
|
||||||
|
.jettyVersion(jettyVersion)
|
||||||
|
.jettyBase(jettyBase)
|
||||||
|
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
String[] args1 = {
|
||||||
|
"--create-startd",
|
||||||
|
"--approve-all-licenses",
|
||||||
|
"--add-to-start=resources,server,http,webapp,deploy,jsp,servlet,servlets,logging-log4j2"
|
||||||
|
};
|
||||||
|
try (DistributionTester.Run run1 = distribution.start(args1))
|
||||||
|
{
|
||||||
|
assertTrue(run1.awaitFor(5, TimeUnit.SECONDS));
|
||||||
|
assertEquals(0, run1.getExitValue());
|
||||||
|
assertTrue(Files.exists(jettyBase.resolve("resources/log4j2.xml")));
|
||||||
|
|
||||||
|
File war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + jettyVersion);
|
||||||
|
distribution.installWarFile(war, "test");
|
||||||
|
|
||||||
|
int port = distribution.freePort();
|
||||||
|
try (DistributionTester.Run run2 = distribution.start("jetty.http.port=" + port))
|
||||||
|
{
|
||||||
|
assertTrue(run2.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS));
|
||||||
|
|
||||||
|
startHttpClient();
|
||||||
|
ContentResponse response = client.GET("http://localhost:" + port + "/test/index.jsp");
|
||||||
|
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||||
|
assertThat(response.getContentAsString(), containsString("Hello"));
|
||||||
|
assertThat(response.getContentAsString(), not(containsString("<%")));
|
||||||
|
assertTrue(Files.exists(jettyBase.resolve("resources/log4j2.xml")));
|
||||||
|
}
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
IO.delete(jettyBase.toFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue