Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit c65f74df authored by Albert Brzozowski's avatar Albert Brzozowski
Browse files

Develop to main

parent 0d93da42
No related branches found
No related tags found
3 merge requests!92Feature/logs added,!90Feature/simpl 10278,!89Develop to main
Showing
with 714 additions and 0 deletions
File moved
### Log4J wrapper
Repository: https://code.europa.eu/simpl/simpl-open/development/contract-billing/common_logging
1. Import in the project
To import into project add maven dependency:
```
<properties>
<simpl.common.logging.version>1.0.0-SNAPSHOT.39.1a139b97</simpl.common.logging.version>
</properties>
<dependency>
<groupId>eu.simpl</groupId>
<artifactId>SIMPL_COMMON_LOGGING</artifactId>
<version>${simpl.common.logging.version}</version>
</dependency>
and repository
<repositories>
<repository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/897/packages/maven</url>
</repository>
</repositories>
```
2. Normal logging:
LOG.info("message");
```
{
"timestamp": "2024-08-20T06:20:12.201Z",
"level": "INFO",
"message": "Application started",
"thread": "main",
"logger": "eu.simpl.simpl_billing.SimplBillingApplication"
}
```
3. Log Http Message
import static eu.simpl.MessageBuilder.buildMessage;
```
LOG.info(buildMessage(HttpLogMessage.builder()
.msg("HTTP request")
.httpStatus("200")
.httpRequestSize("100")
.httpExecutionTime("100")
.user("user")
.build()));
```
Result:
```
{
"timestamp": "2024-08-19T10:32:54.801Z",
"level": "INFO",
"message":
{
"msg": "HTTP request",
"httpStatus": "200",
"httpRequestSize": "100",
"user": "user",
"httpExecutionTime": "100"
},
"thread": "main",
"logger": "eu.simpl.simpl_billing.SimplBillingApplication"
}
```
4. Custom log level BUSINESS
buildMessage method can not be used with slf4, normal logging yes, can be used with sl4j.
example usage:
```
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import static eu.simpl.MessageBuilder.buildMessage;
private static final Logger LOG = LogManager.getLogger(ClassToBeChanged.class);
LOG.log(Level.getLevel("BUSINESS"), buildMessage(LogMessage.builder()
.origin("origin_name")
.destination("destination_name")
.businessOperations(List.of("operation1", "operation2"))
.messageType(MessageType.RESPONSE)
.correlationId("correlation_id")
.httpStatus("200")
.user("user_name")
.msg("Example log message")
.build()));
```
Result:
```
{
"timestamp": "2024-08-12T12:43:18.437+0200",
"level": "BUSINESS",
"message":
{
"msg": "Network",
"messageType": "RESPONSE",
"businessOperations": "[operation1, operation2]",
"origin": "origin_name",
"httpStatus": "200",
"destination": "destination_name",
"correlationId": "correlation_id",
"user": "user_name"
},
"thread": "main",
"logger": "eu.simple.simpl_billing.SimplBillingApplication",
"httpRequestSize": "null",
"httpExecutionTime": "null"
}
```
\ No newline at end of file
documents/images/Export_dashboards_001.png

157 KiB

documents/images/Export_dashboards_002.png

132 KiB

documents/images/Export_dashboards_003.png

77 KiB

documents/images/Import_dashboards_001.png

19.2 KiB

documents/images/Import_dashboards_002.png

106 KiB

documents/images/Import_dashboards_003.png

95 KiB

documents/images/Import_dashboards_004.png

197 KiB

documents/images/Import_dashboards_005.png

204 KiB

documents/images/metricbeat_dashboard_001.png

562 KiB

documents/images/metricbeat_dashboard_002.png

25.6 KiB

documents/images/metricbeat_dashboard_003.png

25.3 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment