Skip to content

Commit 97652bc

Browse files
committed
Slf4j command line properties
1 parent 949a1db commit 97652bc

5 files changed

Lines changed: 189 additions & 1 deletion

File tree

log-exp/slf4j-exp/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>cz.znj.kvr.sw.exp.java.logexp.slf4j</groupId>
9+
<artifactId>slf4j-exp-base</artifactId>
10+
<packaging>pom</packaging>
11+
<version>0.0.1</version>
12+
<name>Slf4j experiments base</name>
13+
<description>Parent of Slf4j experiments</description>
14+
15+
<parent>
16+
<groupId>cz.znj.kvr.sw.exp.java.logexp</groupId>
17+
<artifactId>log-exp-base</artifactId>
18+
<version>0.0.1</version>
19+
<relativePath>../pom.xml</relativePath>
20+
</parent>
21+
22+
<properties>
23+
</properties>
24+
25+
<modules>
26+
<module>slf4j-cmdline-exp</module>
27+
</modules>
28+
29+
<dependencyManagement>
30+
<dependencies>
31+
32+
</dependencies>
33+
</dependencyManagement>
34+
35+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Testing Slf4j command line arguments
2+
3+
```shell
4+
java -Duser.timezone=UTC -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.log.Second=OFF -jar target/slf4j-cmdline-exp-shade
5+
```
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<groupId>cz.znj.kvr.sw.exp.java.logexp.slf4j</groupId>
5+
<artifactId>slf4j-cmdline-exp</artifactId>
6+
<version>0.0.1</version>
7+
<packaging>jar</packaging>
8+
9+
<parent>
10+
<groupId>cz.znj.kvr.sw.exp.java.logexp.slf4j</groupId>
11+
<artifactId>slf4j-exp-base</artifactId>
12+
<version>0.0.1</version>
13+
<relativePath>../pom.xml</relativePath>
14+
</parent>
15+
16+
<build>
17+
<plugins>
18+
19+
<!-- the order matters - maven-shade-plugin somehow consumes the jar created by assembly-plugin -->
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-shade-plugin</artifactId>
23+
<executions>
24+
<execution>
25+
<phase>package</phase>
26+
<goals>
27+
<goal>shade</goal>
28+
</goals>
29+
<configuration>
30+
<finalName>${project.artifactId}-shade</finalName>
31+
<createDependencyReducedPom>false</createDependencyReducedPom>
32+
<filters>
33+
<filter>
34+
<artifact>*:${project.artifactId}-onejar</artifact>
35+
<excludes>
36+
<exclude>*</exclude>
37+
<exclude>**/*</exclude>
38+
</excludes>
39+
</filter>
40+
</filters>
41+
<transformers>
42+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
43+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
44+
<mainClass>cz.znj.kvr.sw.exp.java.logexp.slf4j.cmdline.Print</mainClass>
45+
</transformer>
46+
</transformers>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
52+
<plugin>
53+
<groupId>net.dryuf.maven.plugin</groupId>
54+
<artifactId>dryuf-executable-jar-maven-plugin</artifactId>
55+
<executions>
56+
<execution>
57+
<id>exec-shade</id>
58+
<phase>package</phase>
59+
<goals>
60+
<goal>create-executable</goal>
61+
</goals>
62+
<configuration>
63+
<vmParams>-Xmx256m</vmParams>
64+
<sort>true</sort>
65+
<resourceConfigs>
66+
<resourceConfig>
67+
<pattern>glob:*.jar</pattern>
68+
<minimalCompress>10</minimalCompress>
69+
</resourceConfig>
70+
</resourceConfigs>
71+
<input>${project.build.directory}/${project.artifactId}-shade.${project.packaging}</input>
72+
</configuration>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
77+
<plugin>
78+
<groupId>org.springframework.boot</groupId>
79+
<artifactId>spring-boot-maven-plugin</artifactId>
80+
</plugin>
81+
82+
83+
</plugins>
84+
</build>
85+
86+
<dependencies>
87+
<dependency>
88+
<groupId>org.projectlombok</groupId>
89+
<artifactId>lombok</artifactId>
90+
</dependency>
91+
92+
<dependency>
93+
<groupId>org.testng</groupId>
94+
<artifactId>testng</artifactId>
95+
<scope>test</scope>
96+
</dependency>
97+
98+
<dependency>
99+
<groupId>org.slf4j</groupId>
100+
<artifactId>slf4j-api</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.slf4j</groupId>
104+
<artifactId>slf4j-simple</artifactId>
105+
</dependency>
106+
107+
</dependencies>
108+
109+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cz.znj.kvr.sw.exp.java.logexp.slf4j.cmdline;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
7+
8+
/**
9+
* Test object for JsonIgnore testing.
10+
*/
11+
@Slf4j
12+
public class Print
13+
{
14+
public static void main(String[] args)
15+
{
16+
Logger main = LoggerFactory.getLogger("Main");
17+
main.debug("Debug");
18+
main.info("Info");
19+
main.warn("Warn");
20+
main.error("Error");
21+
22+
Logger second = LoggerFactory.getLogger("Second");
23+
second.debug("Debug");
24+
second.info("Info");
25+
second.warn("Warn");
26+
second.error("Error");
27+
}
28+
}

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<mockito.version>5.12.0</mockito.version>
108108

109109
<log4j.version>2.23.1</log4j.version>
110-
<slf4j.version>2.0.14</slf4j.version>
110+
<slf4j.version>2.0.16</slf4j.version>
111111

112112
<reflections.version>0.10.2</reflections.version>
113113

@@ -690,6 +690,17 @@
690690
<version>${log4j.version}</version>
691691
</dependency>
692692

693+
<dependency>
694+
<groupId>org.slf4j</groupId>
695+
<artifactId>slf4j-api</artifactId>
696+
<version>${slf4j.version}</version>
697+
</dependency>
698+
<dependency>
699+
<groupId>org.slf4j</groupId>
700+
<artifactId>slf4j-simple</artifactId>
701+
<version>${slf4j.version}</version>
702+
</dependency>
703+
693704
<dependency>
694705
<groupId>org.reflections</groupId>
695706
<artifactId>reflections</artifactId>

0 commit comments

Comments
 (0)