我有一个WPF应用程序,它使用Log4Net来记录各种信息。该应用程序运行良好,所有内容都按其应有的方式记录。但是,当滚动浏览“输出”窗口时,我
我正在尝试通过springboot下的配置文件分割我的logback.xml,这是我的方法: logback-prod.xml 我正在尝试通过 springboot 下的配置文件分割我的 logback.xml,这是我的方法: logback-prod.xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml" /> <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:- ${java.io.tmpdir:-/tmp}}/}spring.log}"/> <include resource="org/springframework/boot/logging/logback/file- appender.xml" /> <root level="INFO"> <appender-ref ref="CONSOLE" /> </root> </configuration> logback-dev.xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml" /> <include resource="org/springframework/boot/logging/logback/console-appender.xml" /> <root level="DEBUG"> <appender-ref ref="CONSOLE" /> </root> logback.xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="logback-${spring.profiles.active}.xml"/> <root level="INFO"> <appender-ref ref="FILE" /> <appender-ref ref="CONSOLE" /> </root> 最后使用: -Dspring.profiles.active=dev or -Dspring.profiles.active=prod 我进入控制台: 13:01:44,673 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@2:16 - no applicable action for [configuration], current ElementPath is [[configuration][configuration]] 13:01:44,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:81 - no applicable action for [include], current ElementPath is [[configuration][configuration][include]] 13:01:44,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:89 - no applicable action for [include], current ElementPath is [[configuration][configuration][include]] 13:01:44,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:25 - no applicable action for [root], current ElementPath is [[configuration][configuration][root]] 13:01:44,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@7:39 - no applicable action for [appender-ref], current ElementPath is [[configuration][configuration][root][appender-ref]] 13:01:44,675 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO Spring boot文档建议使用logback-spring.xml而不是logback.xml,并且在其中你可以使用spring配置文件标签: <configuration> <springProfile name="workspace"> ... </springProfile> <springProfile name="dev,prd"> ... </springProfile> </configuration> 如果您想为不同的配置文件使用不同的 logback 配置文件,您可以从 application-*.properties 文件中更改它。 例如,在您的application-prod.properties中,您可以说: logging.config=src/main/resources/logback-prod.xml logback.xml配置文件中的替代方式,配置的分离取决于Spring Profile,如下所示: <!-- Loggers setup according to Spring Profile--> <springProfile name="localdev"> <root level="INFO"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE"/> </root> <logger name="com.myapp" level="debug" additivity="false"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE"/> </logger> </springProfile> <springProfile name="test"> <root level="INFO"> <appender-ref ref="STDOUT"/> </root> <logger name="com.myapp" level="debug"> <appender-ref ref="STDOUT"/> </logger> </springProfile> 包含的 XML 应该具有顶部节点 included 而不是 configuration。 根据:特定于配置文件的配置 您必须用“|”符号而不是“,”逗号分隔配置文件。如下: <springProfile name="dev | staging"> <!-- configuration to be enabled when the "dev" or "staging" profiles are active --> </springProfile>
我是 log4net 的忠实粉丝,但最近,一些人(在我的部门)对它是否包含在我们的项目中提出了质疑,因为每种日志记录方法看起来都很沉重。我认为有