added spring log4j2 support
This commit is contained in:
@@ -31,8 +31,6 @@
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.3.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.3.RELEASE" level="project" />
|
||||
@@ -109,5 +107,11 @@
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:2.1.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jul:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
11
pom.xml
11
pom.xml
@@ -34,6 +34,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -64,6 +70,11 @@
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -12,22 +12,22 @@ package net.irext.decoder.request;
|
||||
*/
|
||||
public class OpenRequest {
|
||||
|
||||
private int indexId;
|
||||
private int remoteIndexId;
|
||||
|
||||
public OpenRequest(int indexId) {
|
||||
this.indexId = indexId;
|
||||
public OpenRequest(int remoteIndexId) {
|
||||
this.remoteIndexId = remoteIndexId;
|
||||
}
|
||||
|
||||
public OpenRequest() {
|
||||
|
||||
}
|
||||
|
||||
public int getIndexId() {
|
||||
return indexId;
|
||||
public int getRemoteIndexId() {
|
||||
return remoteIndexId;
|
||||
}
|
||||
|
||||
public void setIndexId(int indexId) {
|
||||
this.indexId = indexId;
|
||||
public void setRemoteIndexId(int remoteIndexId) {
|
||||
this.remoteIndexId = remoteIndexId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import net.irext.decoder.response.Status;
|
||||
import net.irext.decoder.service.base.AbstractBaseService;
|
||||
import net.irext.decodesdk.bean.ACStatus;
|
||||
import net.irext.decodesdk.utils.Constants;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -32,6 +34,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("/irext")
|
||||
public class IRDecodeService extends AbstractBaseService {
|
||||
|
||||
Logger logger = LogManager.getLogger(IRDecodeService.class);
|
||||
|
||||
private RemoteIndexMapper remoteIndexMapper;
|
||||
|
||||
@Autowired
|
||||
@@ -47,10 +51,12 @@ public class IRDecodeService extends AbstractBaseService {
|
||||
@PostMapping("/open")
|
||||
public ServiceResponse irOpen(@RequestBody OpenRequest openRequest) {
|
||||
try {
|
||||
int indexId = openRequest.getIndexId();
|
||||
int remoteIndexId = openRequest.getRemoteIndexId();
|
||||
|
||||
logger.trace("irOpen API called : " + remoteIndexId);
|
||||
|
||||
ServiceResponse response = new ServiceResponse();
|
||||
RemoteIndex remoteIndex = IndexLogic.getInstance(remoteIndexMapper).getRemoteIndex(indexId);
|
||||
RemoteIndex remoteIndex = IndexLogic.getInstance(remoteIndexMapper).getRemoteIndex(remoteIndexId);
|
||||
if (null == remoteIndex) {
|
||||
response.setStatus(new Status(Constants.ERROR_CODE_NETWORK_ERROR, ""));
|
||||
return response;
|
||||
|
||||
37
src/main/resources/log4j2-spring.xml
Normal file
37
src/main/resources/log4j2-spring.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout
|
||||
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
|
||||
</Console>
|
||||
|
||||
<RollingFile name="RollingFile"
|
||||
fileName="./logs/spring-boot-logger-log4j2.log"
|
||||
filePattern="./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz">
|
||||
<PatternLayout>
|
||||
<pattern>%d %p %C{1.} [%t] %m%n</pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<!-- rollover on startup, daily and when the file reaches
|
||||
10 MegaBytes -->
|
||||
<OnStartupTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy
|
||||
size="10 MB" />
|
||||
<TimeBasedTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<!-- LOG everything at INFO level -->
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console" />
|
||||
<AppenderRef ref="RollingFile" />
|
||||
</Root>
|
||||
|
||||
<!-- LOG "com.baeldung*" at TRACE level -->
|
||||
<Logger name="net.irext" level="trace"></Logger>
|
||||
</Loggers>
|
||||
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user