去除不常用的日志文件打印

pull/1682/head
648540858 2024-11-03 07:38:42 +08:00
parent a6993b35fd
commit 711fefa168
3 changed files with 4 additions and 29 deletions

View File

@ -77,7 +77,7 @@ public class LogServiceImpl implements ILogService {
}
private File getLogDir() {
Logger logger = (Logger) LoggerFactory.getLogger("com.genersoft.iot.vmp");
Logger logger = (Logger) LoggerFactory.getLogger("root");
RollingFileAppender rollingFileAppender = (RollingFileAppender) logger.getAppender("RollingFile");
File rollingFile = new File(rollingFileAppender.getFile());
return rollingFile.getParentFile();

View File

@ -69,8 +69,8 @@ public class LogController {
*
*/
@ResponseBody
@GetMapping("/file")
public void downloadFile(HttpServletResponse response, @RequestParam(required = true) String fileName) {
@GetMapping("/file/{fileName}")
public void downloadFile(HttpServletResponse response, @PathVariable String fileName) {
try {
File file = logService.getFileByName(fileName);
if (file == null || !file.exists() || !file.isFile()) {

View File

@ -55,27 +55,6 @@
</filter>
</appender>
<!-- 生成 error格式日志开始 -->
<appender name="RollingFileError" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--历史日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/error-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>20MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!--设置日志级别,过滤掉info日志,只输入error日志-->
<level>WARN</level>
</filter>
</appender>
<!-- 生成 SIP日志追加 -->
<appender name="SipRollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
@ -97,12 +76,8 @@
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="websocket" />
</root>
<logger name="com.genersoft.iot.vmp" level="info" additivity="true">
<appender-ref ref="RollingFileError"/>
<appender-ref ref="RollingFile"/>
</logger>
</root>
<logger name="com.genersoft.iot.vmp.gb28181.conf.StackLoggerImpl" level="info" additivity="true">
<appender-ref ref="SipRollingFile" />