Skip to content

Commit dbebaf5

Browse files
authored
Merge pull request #12 from microsphere-projects/dev
Sync 'dev' branch
2 parents 18fceba + 443324b commit dbebaf5

21 files changed

Lines changed: 990 additions & 40 deletions

File tree

.github/workflows/maven-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ on:
1212
push:
1313
branches: [ 'dev' ]
1414
pull_request:
15-
branches: [ 'main', 'dev' , 'release' ]
15+
branches: [ 'dev' , 'release' ]
1616

1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
java: [ '17' , '21' , '25' ]
22+
java: [ '8', '11' , '17' , '21' ,' 25' ]
2323
steps:
2424
- name: Checkout Source
2525
uses: actions/checkout@v5

.github/workflows/maven-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
revision:
1717
description: 'The version to publish'
1818
required: true
19-
default: '2.0.0-SNAPSHOT'
19+
default: '1.0.0-SNAPSHOT'
2020

2121
jobs:
2222
build:
@@ -29,7 +29,7 @@ jobs:
2929
- name: Setup Maven Central Repository
3030
uses: actions/setup-java@v5
3131
with:
32-
java-version: '17'
32+
java-version: '11'
3333
distribution: 'temurin'
3434
server-id: ossrh
3535
server-username: MAVEN_USERNAME

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,18 @@ The framework is organized into several key modules:
3535
microsphere-logging-examples | Provides the eamples of Microshere Logging.
3636
microsphere-java-logging | Provides the extensions features for Java Logging.
3737
microsphere-logback | Provides the extensions features for logback.
38+
microsphere-log4j | Provides the extensions features for log4j.
3839
microsphere-log4j2 | Provides the extensions features for log4j2.
3940

40-
## Versions
41-
42-
| **Versions** | **Purpose** | **Latest Version** |
43-
|--------------|------------------------------------|--------------------|
44-
| **0.2.x** | Binary Compatible with Java 17+ | 0.2.0-SNAPSHOT |
45-
| **0.1.x** | Binary Compatible with Java 8 - 25 | 0.1.0-SNAPSHOT |
46-
4741
## Compatibility
4842

49-
### 0.2.x
50-
51-
- Java 17+
52-
- JUnit Jupiter 6.0+
53-
- SLF4J 2.0+
54-
- Logback 1.5+
55-
- Log4j2 2.5+
56-
57-
### 0.1.x
58-
5943
- Java 8+
6044
- JUnit 4+
6145
- JUnit Jupiter 5.13+
6246
- SLF4J 1.7+
47+
- Log4j 1.2+
6348
- Logback 1.2+
64-
- Log4j2 2.0+
49+
- Log4j2 2.4+
6550

6651
## Getting Started
6752

@@ -90,6 +75,7 @@ Then add the specific modules you need:
9075
```xml
9176

9277
<dependencies>
78+
9379
<!-- Microsphere Java Logging -->
9480
<dependency>
9581
<groupId>io.github.microsphere-projects</groupId>
@@ -109,6 +95,19 @@ Then add the specific modules you need:
10995
<version>${logback.version}</version>
11096
</dependency>
11197

98+
<!-- Microsphere Log4j -->
99+
<dependency>
100+
<groupId>io.github.microsphere-projects</groupId>
101+
<artifactId>microsphere-log4j</artifactId>
102+
</dependency>
103+
104+
<!-- Log4j-->
105+
<dependency>
106+
<groupId>log4j</groupId>
107+
<artifactId>log4j</artifactId>
108+
<version>${log4j.version}</version>
109+
</dependency>
110+
112111
<!-- Microsphere Log4j2 -->
113112
<dependency>
114113
<groupId>io.github.microsphere-projects</groupId>

microsphere-log4j/pom.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
<parent>
6+
<groupId>io.github.microsphere-projects</groupId>
7+
<artifactId>microsphere-logging-parent</artifactId>
8+
<version>${revision}</version>
9+
<relativePath>../microsphere-logging-parent/pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<groupId>io.github.microsphere-projects</groupId>
14+
<artifactId>microsphere-log4j</artifactId>
15+
<version>${revision}</version>
16+
<packaging>jar</packaging>
17+
18+
<name>Microsphere :: Logging :: Log4j</name>
19+
<description>Microsphere Logging Log4j</description>
20+
21+
<dependencies>
22+
23+
<!-- Microsphere Logging -->
24+
<dependency>
25+
<groupId>io.github.microsphere-projects</groupId>
26+
<artifactId>microsphere-logging-commons</artifactId>
27+
<version>${revision}</version>
28+
</dependency>
29+
30+
<!-- Log4j-->
31+
<dependency>
32+
<groupId>log4j</groupId>
33+
<artifactId>log4j</artifactId>
34+
<optional>true</optional>
35+
</dependency>
36+
37+
<!-- Testing -->
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>org.junit.jupiter</groupId>
46+
<artifactId>junit-jupiter-engine</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
50+
</dependencies>
51+
52+
</project>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.microsphere.logging.log4j;
19+
20+
import io.microsphere.lang.DelegatingWrapper;
21+
import io.microsphere.logging.AbstractLogger;
22+
import org.apache.log4j.Logger;
23+
24+
import static io.microsphere.logging.log4j.util.LoggerUtils.getLogger;
25+
import static org.apache.log4j.Level.ERROR;
26+
import static org.apache.log4j.Level.WARN;
27+
28+
/**
29+
* The Logger adapter class based Log4j {@link Logger}
30+
*
31+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
32+
* @see AbstractLogger
33+
* @see Logger
34+
* @since 1.0.0
35+
*/
36+
class Log4j2Logger extends AbstractLogger implements DelegatingWrapper {
37+
38+
private final Logger logger;
39+
40+
public Log4j2Logger(String loggerName) {
41+
super(loggerName);
42+
this.logger = getLogger(loggerName);
43+
}
44+
45+
@Override
46+
public boolean isTraceEnabled() {
47+
return this.logger.isTraceEnabled();
48+
}
49+
50+
@Override
51+
public void trace(String message) {
52+
this.logger.trace(message);
53+
}
54+
55+
@Override
56+
public void trace(String message, Throwable t) {
57+
this.logger.trace(message, t);
58+
}
59+
60+
@Override
61+
public boolean isDebugEnabled() {
62+
return this.logger.isDebugEnabled();
63+
}
64+
65+
@Override
66+
public void debug(String message) {
67+
this.logger.debug(message);
68+
69+
}
70+
71+
@Override
72+
public void debug(String message, Throwable t) {
73+
this.logger.debug(message, t);
74+
}
75+
76+
@Override
77+
public boolean isInfoEnabled() {
78+
return this.logger.isInfoEnabled();
79+
}
80+
81+
@Override
82+
public void info(String message) {
83+
this.logger.info(message);
84+
}
85+
86+
@Override
87+
public void info(String message, Throwable t) {
88+
this.logger.info(message, t);
89+
}
90+
91+
@Override
92+
public boolean isWarnEnabled() {
93+
return this.logger.isEnabledFor(WARN);
94+
}
95+
96+
@Override
97+
public void warn(String message) {
98+
this.logger.warn(message);
99+
}
100+
101+
@Override
102+
public void warn(String message, Throwable t) {
103+
this.logger.warn(message, t);
104+
}
105+
106+
@Override
107+
public boolean isErrorEnabled() {
108+
return this.logger.isEnabledFor(ERROR);
109+
}
110+
111+
@Override
112+
public void error(String message) {
113+
this.logger.error(message);
114+
}
115+
116+
@Override
117+
public void error(String message, Throwable t) {
118+
this.logger.error(message, t);
119+
}
120+
121+
@Override
122+
public Object getDelegate() {
123+
return this.logger;
124+
}
125+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package io.microsphere.logging.log4j;
19+
20+
import io.microsphere.logging.Logger;
21+
import io.microsphere.logging.LoggerFactory;
22+
23+
import static io.microsphere.logging.log4j.Log4jLogging.PRIORITY;
24+
25+
/**
26+
* {@link LoggerFactory} for Log4j
27+
*
28+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
29+
* @see LoggerFactory
30+
* @since 1.0.0
31+
*/
32+
public class Log4jLoggerFactory extends LoggerFactory {
33+
34+
public static final String LOG4J_LOGGER_CLASS_NAME = "org.apache.log4j.Logger";
35+
36+
@Override
37+
protected String getDelegateLoggerClassName() {
38+
return LOG4J_LOGGER_CLASS_NAME;
39+
}
40+
41+
@Override
42+
public Logger createLogger(String name) {
43+
return new Log4j2Logger(name);
44+
}
45+
46+
@Override
47+
public int getPriority() {
48+
return PRIORITY;
49+
}
50+
}

0 commit comments

Comments
 (0)