-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#11906] Switch log4j2 configuration format from XML to YAML
- Loading branch information
Showing
5 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
agent-module/agent/src/main/resources/log4j2-agent.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
Configuration: | ||
status: INFO | ||
|
||
Properties: | ||
Property: | ||
- name: "logging_dir" | ||
value: "${sys:pinpoint.log}/${sys:pinpoint.agentId}/" | ||
- name: "rolling-date-format" | ||
value: "%d{yyyy-MM-dd}" | ||
- name: "backupsize" | ||
value: "100m" | ||
- name: "lastmodified" | ||
value: "7d" | ||
- name: "line_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.}:%-3L -- %msg%n" | ||
- name: "simple_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.} -- %msg%n" | ||
- name: "console_message_pattern" | ||
value: "${simple_message_pattern}" | ||
- name: "file_message_pattern" | ||
value: "${simple_message_pattern}" | ||
|
||
Select: | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "local" | ||
Property: | ||
- name: "default-rollover-strategy-max" | ||
value: "5" | ||
- name: "logger-level" | ||
value: "DEBUG" | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "release" | ||
Property: | ||
- name: "default-rollover-strategy-max" | ||
value: "10" | ||
- name: "logger-level" | ||
value: "INFO" | ||
- DefaultArbiter: | ||
Property: | ||
- name: "default-rollover-strategy-max" | ||
value: "5" | ||
- name: "logger-level" | ||
value: "DEBUG" | ||
|
||
Appenders: | ||
Console: | ||
name: console | ||
target: system_out | ||
PatternLayout: | ||
pattern: ${console_message_pattern} | ||
Select: | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "local" | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "release" | ||
ThresholdFilter: | ||
level: WARN | ||
onMatch: ACCEPT | ||
onMismatch: DENY | ||
- DefaultArbiter: | ||
ThresholdFilter: | ||
level: WARN | ||
onMatch: ACCEPT | ||
onMismatch: DENY | ||
RollingFile: | ||
- name: rollingFile | ||
fileName: ${logging_dir}/pinpoint.log | ||
filePattern: ${logging_dir}/pinpoint-${rolling-date-format}-%i.log | ||
PatternLayout: | ||
pattern: ${file_message_pattern} | ||
Policies: | ||
TimeBasedTriggeringPolicy: | ||
interval: 1 | ||
modulate: true | ||
SizeBasedTriggeringPolicy: | ||
size: ${backupsize} | ||
DefaultRolloverStrategy: | ||
max: ${default-rollover-strategy-max} | ||
Delete: | ||
basePath: ${logging_dir}/ | ||
maxDepth: 1 | ||
IfFileName: | ||
glob: "pinpoint-*.log" | ||
IfLastModified: | ||
age: ${lastmodified} | ||
- name: statRollingFile | ||
fileName: ${logging_dir}/pinpoint_stat.log | ||
filePattern: ${logging_dir}/pinpoint_stat-${rolling-date-format}-%i.log | ||
PatternLayout: | ||
pattern: ${file_message_pattern} | ||
Policies: | ||
TimeBasedTriggeringPolicy: | ||
interval: 1 | ||
modulate: true | ||
SizeBasedTriggeringPolicy: | ||
size: ${backupsize} | ||
DefaultRolloverStrategy: | ||
max: ${default-rollover-strategy-max} | ||
Delete: | ||
basePath: ${logging_dir}/ | ||
maxDepth: 1 | ||
IfFileName: | ||
glob: "pinpoint_stat-*.log" | ||
IfLastModified: | ||
age: ${lastmodified} | ||
|
||
Loggers: | ||
Logger: | ||
- name: com.navercorp.pinpoint.metric | ||
level: INFO | ||
additivity: false | ||
AppenderRef: | ||
- ref: statRollingFile | ||
- name: com.navercorp.pinpoint | ||
level: ${logger-level} | ||
additivity: false | ||
AppenderRef: | ||
- ref: console | ||
- ref: rollingFile | ||
- name: io.grpc | ||
level: ${logger-level} | ||
additivity: false | ||
Select: | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "local" | ||
AppenderRef: | ||
- ref: console | ||
- SystemPropertyArbiter: | ||
propertyName: "pinpoint.profiler.profiles.active" | ||
propertyValue: "release" | ||
- DefaultArbiter: | ||
AppenderRef: | ||
- ref: console | ||
AppenderRef: | ||
- ref: rollingFile | ||
- name: io.grpc.Context | ||
level: INFO | ||
additivity: false | ||
AppenderRef: | ||
- ref: console | ||
- ref: rollingFile | ||
- name: io.grpc.netty.Utils | ||
level: INFO | ||
additivity: false | ||
AppenderRef: | ||
- ref: console | ||
- ref: rollingFile | ||
|
||
Root: | ||
level: INFO | ||
AppenderRef: | ||
- ref: console | ||
- ref: rollingFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ng/src/test/java/com/navercorp/pinpoint/profiler/logging/Log4j2LoggingSystemYamlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.navercorp.pinpoint.profiler.logging; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Objects; | ||
|
||
public class Log4j2LoggingSystemYamlTest { | ||
|
||
@Test | ||
public void start() throws URISyntaxException { | ||
URL resource = this.getClass().getClassLoader().getResource(""); | ||
Objects.requireNonNull(resource, "resource"); | ||
Path profilePath = Paths.get(resource.toURI()); | ||
String log4jFile = profilePath.resolve("log4j2-test.yaml").toString(); | ||
System.setProperty("log4j2.component.properties", "YamlConfigurationFactory"); | ||
|
||
|
||
try (Log4j2LoggingSystem loggingSystem = new Log4j2LoggingSystem(profilePath)) { | ||
loggingSystem.start(); | ||
|
||
Logger test = LogManager.getLogger("test"); | ||
test.debug("test"); | ||
|
||
String configLocation = loggingSystem.getConfigLocation(); | ||
// Assertions.assertEquals(log4jFile, configLocation); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
agent-module/profiler-logging/src/test/resources/log4j2-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Configuration: | ||
status: INFO | ||
|
||
Properties: | ||
Property: | ||
- name: "console_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %clr{%-5level} %clr{%-40.40logger{1.}}{cyan}:%3L -- %msg%n" | ||
- name: "file_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.}:%3L -- %msg%n" | ||
|
||
Appenders: | ||
Console: | ||
name: console | ||
target: system_out | ||
PatternLayout: | ||
pattern: ${file_message_pattern} | ||
|
||
Loggers: | ||
Logger: | ||
- name: com.navercorp.pinpoint | ||
level: DEBUG | ||
additivity: false | ||
AppenderRef: | ||
- ref: console | ||
|
||
Root: | ||
level: DEBUG | ||
AppenderRef: | ||
- ref: console |