如何配置log4j和Selenium Grid?
当我使用 Ant 启动 Grid hub 时,默认情况下日志记录全部在控制台上。我想知道是否有一种方法可以更改 Selenium Grid 的 build.xml
文件并在其中包含 log4j
记录器。据我所知,我可以使用 -logfile
选项为 Ant 本身指定一个日志文件。但这会导致每次启动网格时日志文件都被覆盖。我想确保日志文件在达到阈值后自动重命名,以便更好地维护。任何帮助,如果可能的话,一些关于如何做到这一点的示例将不胜感激(我是使用 log4j
的新手,这就是为什么我要求一些示例来满足此特定需求)。
When I launch a Grid hub using Ant, the logging is all by default on the console. I would like to know if there is a way wherein I can alter the build.xml
file of Selenium Grid and include a log4j
logger into it. I understand that I can specify a log file to Ant itself using the -logfile
option. But this would cause the log file to be overwritten everytime the grid is launched. I want to ensure that the log files are automatically renamed after a threshold is reached for better maintenance. Any help and if possible some examples on how to do it would be greatly appreciated (I am new to using log4j
which is why I am asking for some sample for this specific need).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
启动 Selenium 时,您需要指定 Log4j 存档及其配置文件的位置。在以下示例中,我更新了类路径以加载位于
/etc/selenium
目录中的log4j.hub.properties
配置文件和log4j.properties 文件。 jar
位于/usr/lib/selenium
目录中。我还设置了一些额外的日志文件:然后您可以使用类似以下内容来实现您正在寻找的内容:
您可能需要查看 此页面了解有关 Selenium 日志记录如何工作的更多信息。
You need to specify the location of the Log4j archive as well as its configuration file when starting up Selenium. In the following example, I've updated the classpath to load the
log4j.hub.properties
configuration file located in the/etc/selenium
directory and thelog4j.jar
located in the/usr/lib/selenium
directory. I've also setup some additional log files:Then you can have something like the following to achieve what you are looking for:
You might want to look at this page for more information about how Selenium logging is working.