[JAVA-18156] (#13787)

* [JAVA-18156]

* [JAVA-18156] Revert changes + use correct profile
This commit is contained in:
panos-kakos 2023-04-09 17:48:23 +03:00 committed by GitHub
parent b280691134
commit 4272773056
3 changed files with 21 additions and 48 deletions

View File

@ -68,46 +68,19 @@
<proc>none</proc>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
<logging.folder.path>${java.io.tmpdir}/${maven.build.timestamp}/logfile.json</logging.folder.path>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>integration-lite-first</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*ManualTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
<includes>
<include>**/*IntegrationTest.java</include>
<include>**/*IntTest.java</include>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
<logging.folder.path>${java.io.tmpdir}/${maven.build.timestamp}/logfile.json</logging.folder.path>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<commons-dbcp2.version>2.9.0</commons-dbcp2.version>

View File

@ -21,7 +21,7 @@ import com.baeldung.logging.log4j2.tests.jdbc.ConnectionFactory;
@RunWith(JUnit4.class)
public class CustomLoggingIntegrationTest {
private static String logFilePath = System.getProperty("logging.folder.path");
@BeforeClass
@ -34,7 +34,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithDefaultConfig_whenLogToConsole_thanOK() throws Exception {
public void givenLoggerWithDefaultConfig_whenLogToConsole_thenOK() throws Exception {
Logger logger = LogManager.getLogger(getClass());
Exception e = new RuntimeException("This is only a test!");
@ -43,7 +43,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithConsoleConfig_whenLogToConsoleInColors_thanOK() throws Exception {
public void givenLoggerWithConsoleConfig_whenLogToConsoleInColors_thenOK() throws Exception {
Logger logger = LogManager.getLogger("CONSOLE_PATTERN_APPENDER_MARKER");
Exception e = new RuntimeException("This is only a test!");
@ -56,7 +56,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithConsoleConfig_whenFilterByMarker_thanOK() throws Exception {
public void givenLoggerWithConsoleConfig_whenFilterByMarker_thenOK() throws Exception {
Logger logger = LogManager.getLogger("CONSOLE_PATTERN_APPENDER_MARKER");
Marker appError = MarkerManager.getMarker("APP_ERROR");
Marker connectionTrace = MarkerManager.getMarker("CONN_TRACE");
@ -66,7 +66,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithConsoleConfig_whenFilterByThreadContext_thanOK() throws Exception {
public void givenLoggerWithConsoleConfig_whenFilterByThreadContext_thenOK() throws Exception {
Logger logger = LogManager.getLogger("CONSOLE_PATTERN_APPENDER_THREAD_CONTEXT");
ThreadContext.put("userId", "1000");
logger.info("This is a log-visible user login. Maybe from an admin account?");
@ -75,7 +75,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithAsyncConfig_whenLogToJsonFile_thanOK() throws Exception {
public void givenLoggerWithAsyncConfig_whenLogToJsonFile_thenOK() throws Exception {
Logger logger = LogManager.getLogger("ASYNC_JSON_FILE_APPENDER");
final int count = 88;
@ -90,7 +90,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithFailoverConfig_whenLog_thanOK() throws Exception {
public void givenLoggerWithFailoverConfig_whenLog_thenOK() throws Exception {
Logger logger = LogManager.getLogger("FAIL_OVER_SYSLOG_APPENDER");
Exception e = new RuntimeException("This is only a test!");
@ -103,7 +103,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithJdbcConfig_whenLogToDataSource_thanOK() throws Exception {
public void givenLoggerWithJdbcConfig_whenLogToDataSource_thenOK() throws Exception {
Logger logger = LogManager.getLogger("JDBC_APPENDER");
final int count = 88;
@ -122,7 +122,7 @@ public class CustomLoggingIntegrationTest {
}
@Test
public void givenLoggerWithRollingFileConfig_whenLogToXMLFile_thanOK() throws Exception {
public void givenLoggerWithRollingFileConfig_whenLogToXMLFile_thenOK() throws Exception {
Logger logger = LogManager.getLogger("XML_ROLLING_FILE_APPENDER");
final int count = 88;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns:xi="http://www.w3.org/2001/XInclude"
<Configuration xmlns:xi="http://www.w3.org/2001/XInclude"
packages="com.baeldung" status="WARN">
<Appenders>
<xi:include
@ -20,7 +20,7 @@
<KeyValuePair key="myCustomField" value="myCustomValue" />
</JsonLayout>
</Console>
<File name="JSONLogfileAppender" fileName="${sys:logging.folder.path}">
<File name="JSONLogfileAppender" fileName="${sys:logging.folder.path}" >
<JSONLayout compact="true" eventEol="true" />
<BurstFilter level="INFO" rate="2" maxBurst="10" />
</File>