gpt4 book ai didi

java - 如何为 Selenium WebDriverManager 配置 Log4j?出现log4j错误

转载 作者:行者123 更新时间:2023-12-01 23:19:01 27 4
gpt4 key购买 nike

此软件包有错误 - io.github.bonigarcia.wdm.Preferences。我不明白应该如何配置 log4j.xml 文件来支持此内部记录器。我根本不需要这个 WebDriverManager 记录器。只是满足我的项目需求的跟踪级别。


log4j:WARN No appenders could be found for logger (io.github.bonigarcia.wdm.Preferences). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

package io.github.bonigarcia.wdm;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Preferences {
final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
static final String TTL = "-ttl";
java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(WebDriverManager.class);


我尝试阅读一些手册 - 如何正确配置 log4j.xml。并且也厌倦了配置 log4j.properties 文件。

现在 log4j.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

How should I add an WARN appender for io.github.bonigarcia.wdm.Preferences? Or how should I exclude WebDriverManagers logger?

最佳答案

pom.xml 文件中设置此依赖项以排除 SLF4J 错误:

    <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.28</version>
<scope>test</scope>
</dependency>

关于java - 如何为 Selenium WebDriverManager 配置 Log4j?出现log4j错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58335006/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com