使用 logback 配置 控制 sip 日志
This commit is contained in:
parent
431d6f90cb
commit
5599fe010a
@ -14,7 +14,6 @@ import java.util.List;
|
|||||||
@Order(0)
|
@Order(0)
|
||||||
@Data
|
@Data
|
||||||
public class SipConfig {
|
public class SipConfig {
|
||||||
|
|
||||||
private List<String> ip;
|
private List<String> ip;
|
||||||
|
|
||||||
private List<String> showIp;
|
private List<String> showIp;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.skcks.docking.gb28181.core.sip.logger;
|
package cn.skcks.docking.gb28181.core.sip.logger;
|
||||||
|
|
||||||
|
import cn.skcks.docking.gb28181.config.sip.SipConfig;
|
||||||
import gov.nist.core.StackLogger;
|
import gov.nist.core.StackLogger;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class DefaultProperties {
|
public class DefaultProperties {
|
||||||
|
|
||||||
public static Properties getProperties(String name, boolean sipLog) {
|
public static Properties getProperties(String name) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty("javax.sip.STACK_NAME", name);
|
properties.setProperty("javax.sip.STACK_NAME", name);
|
||||||
// properties.setProperty("javax.sip.IP_ADDRESS", ip);
|
// properties.setProperty("javax.sip.IP_ADDRESS", ip);
|
||||||
@ -49,14 +49,9 @@ public class DefaultProperties {
|
|||||||
* sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE
|
* sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE
|
||||||
*/
|
*/
|
||||||
Logger logger = LoggerFactory.getLogger(SipConfig.class);
|
Logger logger = LoggerFactory.getLogger(SipConfig.class);
|
||||||
if (sipLog) {
|
|
||||||
properties.setProperty("gov.nist.javax.sip.STACK_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.StackLoggerImpl");
|
properties.setProperty("gov.nist.javax.sip.STACK_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.StackLoggerImpl");
|
||||||
properties.setProperty("gov.nist.javax.sip.SERVER_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.ServerLoggerImpl");
|
properties.setProperty("gov.nist.javax.sip.SERVER_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.ServerLoggerImpl");
|
||||||
properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true");
|
properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true");
|
||||||
logger.info("[SIP日志]已开启");
|
|
||||||
}else {
|
|
||||||
logger.info("[SIP日志]已关闭");
|
|
||||||
}
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class SipServiceImpl implements SipService {
|
|||||||
|
|
||||||
public void listen(String ip, int port){
|
public void listen(String ip, int port){
|
||||||
try{
|
try{
|
||||||
sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties("GB28181_SIP_LOG",true));
|
sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties("GB28181_SIP"));
|
||||||
sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
|
sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
|
||||||
// sipStack.setMessageProcessorFactory();
|
// sipStack.setMessageProcessorFactory();
|
||||||
try {
|
try {
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 28181
|
port: 28181
|
||||||
|
|
||||||
|
project:
|
||||||
|
version: @project.version@
|
||||||
|
@ -49,5 +49,6 @@
|
|||||||
<!--<appender-ref ref="file" />-->
|
<!--<appender-ref ref="file" />-->
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
<logger name="cn.skcks.docking.gb28181.core.sip.logger" level="INFO" />
|
||||||
<logger name="cn.skcks.docking.gb28181" level="DEBUG" />
|
<logger name="cn.skcks.docking.gb28181" level="DEBUG" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -2,12 +2,9 @@ package cn.skcks.docking.gb28181.test;
|
|||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.net.url.UrlBuilder;
|
|
||||||
import cn.hutool.core.net.url.UrlPath;
|
|
||||||
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||||
import cn.skcks.docking.gb28181.common.json.JsonUtils;
|
import cn.skcks.docking.gb28181.common.json.JsonUtils;
|
||||||
import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig;
|
import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig;
|
||||||
import cn.skcks.docking.gb28181.media.dto.config.FFMpegConfig;
|
|
||||||
import cn.skcks.docking.gb28181.media.dto.config.HookConfig;
|
import cn.skcks.docking.gb28181.media.dto.config.HookConfig;
|
||||||
import cn.skcks.docking.gb28181.media.dto.config.ServerConfig;
|
import cn.skcks.docking.gb28181.media.dto.config.ServerConfig;
|
||||||
import cn.skcks.docking.gb28181.media.dto.media.GetMediaList;
|
import cn.skcks.docking.gb28181.media.dto.media.GetMediaList;
|
||||||
@ -24,7 +21,6 @@ import cn.skcks.docking.gb28181.media.dto.version.VersionResp;
|
|||||||
import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
|
import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -34,7 +30,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
Loading…
Reference in New Issue
Block a user