• notice
  • Congratulations on the launch of the Sought Tech site

The logger records are displayed on the console, but the troubleshooting is not displayed in the log output file

 Scenes:

In the code, logger.info is used to output data to the specified file, and then logstash is used to collect the required data and insert it into es.

Phenomenon: 

The record break point output by logger.info is displayed on the console, but the log output content cannot be found in the configured log output file.

log4j configuration

as follows:


Breakpoint troubleshooting

 logger.info has a printout on the console, but there is nothing in the configured log output file

14:53:02.737 [http-nio-8082-exec-3] INFO com.gisquest.platform.modules.funcmgr.web.FuncGroupItemController - {"opertion":"删除菜单分组\u201c在办办件1\u201d","ip":"192.168.100.88","staffname":"系统管理员","model":"菜单定制","id":"分组id:5b2a9f1e-828e-11ed-971c-3c7c3fba0919","userid":"8c7d3682-c080-4d4a-947f-af08e64576a2","url":"http://GisqPlatformDesigner-Rest.gisquest.com:8082/GisqPlatformDesigner-Rest/service//funcmgr/delete-group-item/5b2a9f1e-828e-11ed-971c-3c7c3fba0919","mac":"","object":"分组id:5b2a9f1e-828e-11ed-971c-3c7c3fba0919;分组名称:在办办件1;父分组:菜单管理","username":"admin"}

Cause Analysis:

Analysis 1: It stands to reason that my log output can be seen in the control, and it stands to reason that it will also be written to the platform.log configuration file.

 Analysis 2: jar package conflict The online prompt said that the log package conflicted. I took a look at the log package in the project as follows, and there were two more logback packages.

logback-core-1.2.3.jar
logback-class-1.2.3.jar

log4j-1.2.17.jar
log4j-api-2.17.2,jar
log4j-core-2.17.2.jar

slf4-api-1.17.10.jar
slf4j-kig4j12-1.7.10.jar
jcl-over-slf4j-1.7.10.jar
jul-to-slf4j-1.7.10.jar

insert image description here


Check 1: The logback package is imported from which dependency?

Use the idea tool to print out the dependency tree using the mvn dependency:tree command,

Positioning: It is found that logback is introduced into gisquest-log-client-Spring4:jar.

] +- com.gisquest.cloud:gisquest-log-client-Spring4:jar:1.0:compile
[INFO] |  \- com.gisquest.cloud:gisquest-log-client-common:jar:1.0:compile
[INFO] |     +- com.alibaba:fastjson:jar:1.2.83:compile
[INFO] |     +- org.projectlombok:lombok:jar:1.18.10:compile
[INFO] |     +- com.gisquest.cloud:gisquest-log-common:jar:1.0:compile
[INFO] |     |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile
[INFO] |     |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile
[INFO] |     |  \- cn.hutool:hutool-core:jar:5.6.6:compile
[INFO] |     +- com.gisquest.cloud:gisquest-log-autoscan:jar:1.0:compile
[INFO] |     |  \- com.gisquest.cloud:gisquest-log-entity:jar:1.0:compile
[INFO] |     |     +- com.baomidou:mybatis-plus-annotation:jar:3.4.2:compile
[INFO] |     |     \- io.swagger:swagger-annotations:jar:1.5.22:compile
[INFO] |     +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |     +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |     \- cn.hutool:hutool-all:jar:5.8.3:compile
[INFO] +- com.gisquest:GisqPlatform-Apollo:jar:1.0.0:compile
[INFO] |  +- com.ctrip.framework.apollo:apollo-client:jar:1.3.0:compile
[INFO] |  |  \- com.google.inject:guice:jar:4.1.0:compile
[INFO] |  |     +- javax.inject:javax.inject:jar:1:compile
[INFO] |  |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- com.ctrip.framework.apollo:apollo-core:jar:1.3.0:compile
[INFO] |     \- com.google.code.gson:gson:jar:2.8.0:compile
[INFO] \- com.gisquest.wcspsdk:wcspsdk-server:jar:2.3.0.4-RELEASE:compile

Solution: exclude logback from the package

<!-- Log Center Client -->
         <dependency>
             <groupId>com.gisquest.cloud</groupId>
             <artifactId>gisquest-log-client-Spring4</artifactId>
             <version>1.0</version>
             <exclusions>
                 <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-core</artifactId>
                </exclusion>
               </exclusions>
         </dependency>

 insert it into es.

Phenomenon: 

The record break point output by logger.info is displayed on the console, but the log output content cannot be found in the configured log output file.

log4j configuration

as follows:


Breakpoint troubleshooting

 logger.info has a printout on the console, but there is nothing in the configured log output file

14:53:02.737 [http-nio-8082-exec-3] INFO com.gisquest.platform.modules.funcmgr.web.FuncGroupItemController - {"opertion":"删除菜单分组\u201c在办办件1\u201d","ip":"192.168.100.88","staffname":"系统管理员","model":"菜单定制","id":"分组id:5b2a9f1e-828e-11ed-971c-3c7c3fba0919","userid":"8c7d3682-c080-4d4a-947f-af08e64576a2","url":"http://GisqPlatformDesigner-Rest.gisquest.com:8082/GisqPlatformDesigner-Rest/service//funcmgr/delete-group-item/5b2a9f1e-828e-11ed-971c-3c7c3fba0919","mac":"","object":"分组id:5b2a9f1e-828e-11ed-971c-3c7c3fba0919;分组名称:在办办件1;父分组:菜单管理","username":"admin"}

Cause Analysis:

Analysis 1: It stands to reason that my log output can be seen in the control, and it stands to reason that it will also be written to the platform.log configuration file.

 Analysis 2: jar package conflict The online prompt said that the log package conflicted. I took a look at the log package in the project as follows, and there were two more logback packages.

logback-core-1.2.3.jar
logback-class-1.2.3.jar

log4j-1.2.17.jar
log4j-api-2.17.2,jar
log4j-core-2.17.2.jar

slf4-api-1.17.10.jar
slf4j-kig4j12-1.7.10.jar
jcl-over-slf4j-1.7.10.jar
jul-to-slf4j-1.7.10.jar

insert image description here


Check 1: The logback package is imported from which dependency?

Use the idea tool to print out the dependency tree using the mvn dependency:tree command,

Positioning: It is found that logback is introduced into gisquest-log-client-Spring4:jar.

] +- com.gisquest.cloud:gisquest-log-client-Spring4:jar:1.0:compile[INFO] |  \- com.gisquest.cloud:gisquest-log-client-common:jar:1.0:compile[INFO] |     +- com.alibaba:fastjson:jar:1.2.83:compile[INFO] |     +- org.projectlombok:lombok:jar:1.18.10:compile[INFO] |     +- com.gisquest.cloud:gisquest-log-common:jar:1.0:compile[INFO] |     |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile[INFO] |     |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile[INFO] |     |  \- cn.hutool:hutool-core:jar:5.6.6:compile[INFO] |     +- com.gisquest.cloud:gisquest-log-autoscan:jar:1.0:compile[INFO] |     |  \- com.gisquest.cloud:gisquest-log-entity:jar:1.0:compile[INFO] |     |     +- com.baomidou:mybatis-plus-annotation:jar:3.4.2:compile[INFO] |     |     \- io.swagger:swagger-annotations:jar:1.5.22:compile[INFO] |     +- ch.qos.logback:logback-core:jar:1.2.3:compile[INFO] |     +- ch.qos.logback:logback-classic:jar:1.2.3:compile[INFO] |     \- cn.hutool:hutool-all:jar:5.8.3:compile[INFO] +- com.gisquest:GisqPlatform-Apollo:jar:1.0.0:compile[INFO] |  +- com.ctrip.framework.apollo:apollo-client:jar:1.3.0:compile[INFO] |  |  \- com.google.inject:guice:jar:4.1.0:compile[INFO] |  |     +- javax.inject:javax.inject:jar:1:compile[INFO] |  |     \- aopalliance:aopalliance:jar:1.0:compile[INFO] |  \- com.ctrip.framework.apollo:apollo-core:jar:1.3.0:compile[INFO] |     \- com.google.code.gson:gson:jar:2.8.0:compile[INFO] \- com.gisquest.wcspsdk:wcspsdk-server:jar:2.3.0.4-RELEASE:compile

Solution: exclude logback from the package

<!-- 日志中心客户端 --><dependency><groupId>com.gisquest.cloud</groupId><artifactId>gisquest-log-client-Spring4</artifactId><version>1.0</version><exclusions><exclusion><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId></exclusion><exclusion><groupId>ch.qos.logback</groupId><artifactId>logback-core</artifactId></exclusion></exclusions></dependency>

Test again after exclusion, everything is normal

 


2022-12-23 15:00:13,529 INFO [platform.modules.funcmgr.web.FuncGroupItemController] - {"opertion":"Delete menu group\u201c in-process item 1\u201d","ip":"192.168. 100.88","staffname":"system administrator","model":"menu customization","id":"group id:5b2a9f1e-828e-11ed-971c-3c7c3fba0919","userid":"8c7d3682-c080- 4d4a-947f-af08e64576a2","url":"http://GisqPlatformDesigner-Rest.gisquest.com:8082/GisqPlatformDesigner-Rest/service//funcmgr/delete-group-item/5b2a9f1e-828e-11ed-971c-3c7c3fba0919 ","mac":"","object":"group id: 5b2a9f1e-828e-11ed-971c-3c7c3fba0919; group name: in-process 1; parent group: menu management","username":"admin" }


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+