英文:
Get email with execution log even when no error exists
问题
My requirements:
- 如果在执行过程中出现错误,我需要发送一封电子邮件,其中包含错误日志以及具有日志级别 >= INFO 的先前日志。 我的当前配置满足此要求。
- 如果执行中没有错误,我需要电子邮件包含执行过程中记录的所有消息,其中日志级别 >= INFO。 需要帮助。 我当前的配置不满足此要求。
我在我的Maven项目中有以下的log4j2 xml文件:
<Configuration status="INFO">
<Properties>
...(其他属性)
</Properties>
<Appenders>
...(其他Appenders)
</Appenders>
<Loggers>
...(其他Loggers)
</Loggers>
</Configuration>
在执行以下代码后:
private static Logger log = LogManager.getLogger("test");
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warn");
log.error("error");
log.fatal("fatal");
如预期的那样,我收到了两封电子邮件,内容如下:
第一封电子邮件(由于记录器的日志级别设置为INFO,trace和debug被忽略):
2020-07-23 03:18:31.780 [main] INFO test - info
2020-07-23 03:18:31.789 [main] WARN test - warn
2020-07-23 03:18:31.790 [main] ERROR test - error
第二封电子邮件:
2020-07-23 03:18:31.790 [main] FATAL test - fatal
到目前为止,一切都按预期工作。
问题:在执行以下代码后,我没有收到任何电子邮件(因为没有日志级别为ERROR或FATAL的日志):
private static Logger log = LogManager.getLogger("test");
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warn");
在这种情况下,是否可能收到包含以下内容的单封电子邮件? 如果是,如何实现?
2020-07-23 03:18:31.780 [main] INFO test - info
2020-07-23 03:18:31.789 [main] WARN test - warn
已解决:
如@RemkoPopma所建议,我必须决定在执行期间没有错误的情况下电子邮件的触发条件。 我分析了我的日志并检查了每当执行没有问题/错误时,我都会发送包含文本“Suite execution completed”的日志消息。 因此,我使用了SMTP appender的复合过滤器,如下所示:
<SMTP name="mailLog" subject="${mailSubject}" to="${recipients}"
from="${sender}" smtpHost="${host}" smtpPort="${port}"
smtpUsername="${username}" smtpPassword="${password}"
buffersize="${bufferSize}" smtpProtocol="${protocol}"
ignoreExceptions="false" smtpdebug="true">
<PatternLayout pattern="${standardPattern}" />
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT"
onMismatch="NEUTRAL" />
<RegexFilter regex="^.*Suite execution completed.*$"
onMatch="ACCEPT" onMisMatch="DENY" />
</Filters>
</SMTP>
解释:
- 如果在执行过程中出现错误,则阈值过滤器接受日志并发送包含该错误日志以及缓冲区中的所有其他日志(满足我的要求1)的电子邮件。
- 如果在执行过程中没有错误,那么日志消息(级别<ERROR)将通过Threshold过滤器(onMisMatch=NEUTRAL)传递到序列中的下一个过滤器,即RegexFilter。 RegexFilter将不断拒绝(并将它们添加到缓冲区)日志,直到我们得到包含文本“Suite execution completed”的日志为止。 一
英文:
My requirements:
- If there an error is encountered during the execution, I need to send an email having the error log as well as previous logs with log levels >= INFO. My current configuration satisfy this requirement.
- If there are no errors in the execution, I need the email to have all the messages logged during the execution with log levels >=INFO. Need help here. My current configuration does not satisfy this requirement.
I have the following log4j2 xml file in my maven project:
<Configuration status="INFO">
<Properties>
<Property name="standardPattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %m%n</Property>
<Property name="mailSubject">Execution Log</Property>
<Property name="recipients">xxxx@gmail.com</Property>
<Property name="sender">xx@gmail.com</Property>
<Property name="host">smtp.gmail.com</Property>
<Property name="port">587</Property>
<Property name="username">xx@gmail.com</Property>
<Property name="protocol">smtp</Property>
<Property name="password">secret</Property>
<Property name="bufferSize">512</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${standardPattern}" />
</Console>
<SMTP name="mailLog" subject="${mailSubject}" to="${recipients}"
from="${sender}" smtpHost="${host}" smtpPort="${port}"
smtpUsername="${username}" smtpPassword="${password}"
buffersize="${bufferSize}" smtpProtocol="${protocol}"
ignoreExceptions="false" smtpdebug="true">
<PatternLayout pattern="${standardPattern}" />
<ThresholdFilter level="error" onMatch="NEUTRAL"
onMismatch="DENY" />
</SMTP>
<Async name="asyncMail">
<AppenderRef ref="mailLog" />
</Async>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
</Root>
<Logger name="test" level="info" additivity="false">
<AppenderRef ref="Console" />
<AppenderRef ref="asyncMail"/>
</Logger>
</Loggers>
</Configuration>
On executing the following code:
private static Logger log = LogManager.getLogger("test");
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warn");
log.error("error");
log.fatal("fatal");
As expected, I get 2 emails with the following contents:
1st email(trace and debug were ignored as the logger's log level is set to info):
2020-07-23 03:18:31.780 [main] INFO test - info
2020-07-23 03:18:31.789 [main] WARN test - warn
2020-07-23 03:18:31.790 [main] ERROR test - error
2nd email:
2020-07-23 03:18:31.790 [main] FATAL test - fatal
Until now, everything works as expected.
Issue: On executing the following code, I did not receive any email(because there were no logs with level = ERROR or FATAL)
private static Logger log = LogManager.getLogger("test");
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warn");
Is such a case, is it possible to get a single email having the following contents? If yes, how?
2020-07-23 03:18:31.780 [main] INFO test - info
2020-07-23 03:18:31.789 [main] WARN test - warn
RESOLVED:
As told by @RemkoPopma, I had to decide the trigger for the email in case there was no error during the execution. I analysed my logs and checked that whenever the execution gets completed without any issues/errors, I send the log message Suite execution completed
. So, keeping that in mind, I ended by using the composite filter for the SMTP appender as shown below:
<SMTP name="mailLog" subject="${mailSubject}" to="${recipients}"
from="${sender}" smtpHost="${host}" smtpPort="${port}"
smtpUsername="${username}" smtpPassword="${password}"
buffersize="${bufferSize}" smtpProtocol="${protocol}"
ignoreExceptions="false" smtpdebug="true">
<PatternLayout pattern="${standardPattern}" />
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT"
onMismatch="NEUTRAL" />
<RegexFilter regex="^.*Suite execution completed.*$"
onMatch="ACCEPT" onMisMatch="DENY" />
</Filters>
</SMTP>
Explanation:
- In case there is an error during the execution, the threshold filter accepts the log and sends the email displaying that error log along with all the other previous logs(satisfying my requirement 1)
- In case there is no error during the execution, then log messages(level<ERROR) pass through the Threshold filter(onMisMatch=NEUTRAL) to the next filter in sequence i.e., RegexFilter. The RegexFilter will keep on denying(and adding them to buffer) the logs unless we get a log containing the text
Suite execution completed
. Once this log is encountered, an email is trigerred containing the final log message along with all the previous logs stored in the buffer.
The following was sent to me after the execution got completed without any error:
2020-07-23 17:08:44.269 [main] INFO Expedia - Suite execution started
2020-07-23 17:08:44.283 [main] INFO Expedia - Launching the "chrome" Browser
2020-07-23 17:08:49.590 [main] INFO Expedia - Maximizing browser window
2020-07-23 17:08:51.865 [main] INFO Expedia - Reading test data from the excel file at locaton - E:\Testing\WebTesting\WebTesting\src\test\resources\testData\oneWayFlight_checkEconomyClassResultsDefaultDate.xlsx
2020-07-23 17:08:55.632 [main] INFO Expedia - Deleting all the cookies
2020-07-23 17:08:55.649 [main] INFO Expedia - Navigating to URL - https://www.expedia.co.in/
2020-07-23 17:09:06.845 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:09:06.846 [main] INFO Expedia - |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>>>>>>>>>>>>>>>>>STARTING TEST<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|
2020-07-23 17:09:06.847 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:09:06.848 [main] INFO Expedia - Starting Test execution for the test "oneWayFlight_checkEconomyClassResultsDefaultDate" with test data - {Leaving from=Mumbai, Going to=Chennai, Departure Date=29/12/20, Travel Class=Economy, Adults=2.0, Children=1.0, Infants=1.0}
2020-07-23 17:09:07.281 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //span[text()='Flights']]
2020-07-23 17:09:08.131 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //span[text()='One-way']]
2020-07-23 17:09:12.832 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: [data-stid='location-field-leg1-origin-menu-trigger']]
2020-07-23 17:09:13.663 [main] INFO Expedia - Sending text "Mumbai" to the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: location-field-leg1-origin]
2020-07-23 17:09:14.981 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //strong[contains(text(),'Mumbai')]]
2020-07-23 17:09:15.377 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: [data-stid='location-field-leg1-destination-menu-trigger']]
2020-07-23 17:09:15.652 [main] INFO Expedia - Sending text "Chennai" to the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: location-field-leg1-destination]
2020-07-23 17:09:18.038 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //strong[contains(text(),'Chennai')]]
2020-07-23 17:09:18.758 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: d1-btn]
2020-07-23 17:09:19.151 [main] INFO Expedia - Scrolling the page to bring the object "[[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker]" in the visible area
2020-07-23 17:09:20.778 [main] INFO Expedia - The text "July 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:20.850 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:09:21.069 [main] INFO Expedia - The text "August 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:21.106 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:09:21.279 [main] INFO Expedia - The text "September 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:21.318 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:09:21.481 [main] INFO Expedia - The text "October 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:21.519 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:09:21.796 [main] INFO Expedia - The text "November 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:21.935 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:09:22.498 [main] INFO Expedia - The text "December 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:09:22.710 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //div[@class='uitk-new-date-picker-month'][1]//button[@data-day='29']]
2020-07-23 17:09:23.216 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button[data-stid='apply-date-picker'] > span]
2020-07-23 17:09:23.712 [main] INFO Expedia - Scrolling to the page top in one-go
2020-07-23 17:09:24.048 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: preferred-class-input-trigger]
2020-07-23 17:09:24.634 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //a[@class='uitk-list-item' and contains(text(),'Economy')]]
2020-07-23 17:09:24.830 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: a[data-testid='travelers-field']]
2020-07-23 17:09:25.240 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: adult-input-0]
2020-07-23 17:09:25.304 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='adult-input-0']/following-sibling::button]
2020-07-23 17:09:25.472 [main] INFO Expedia - The value of the attribute("value") is "2" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: adult-input-0]
2020-07-23 17:09:25.540 [main] INFO Expedia - The value of the attribute("value") is "0" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: child-input-0]
2020-07-23 17:09:25.607 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='child-input-0']/following-sibling::button]
2020-07-23 17:09:25.847 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: child-input-0]
2020-07-23 17:09:25.914 [main] INFO Expedia - The value of the attribute("value") is "0" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: infant-input-0]
2020-07-23 17:09:25.965 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='infant-input-0']/following-sibling::button]
2020-07-23 17:09:26.360 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: infant-input-0]
2020-07-23 17:09:26.437 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //button[contains(text(),'Done')]]
2020-07-23 17:09:26.908 [main] INFO Expedia - Capturing screenshot of the visible area and saving at path - E:\Testing\WebTesting\WebTesting\screenshots\23-Jul-20\05.08 PM\oneWayFlight_checkEconomyClassResultsDefaultDate\Dataset1_SS1.jpg
2020-07-23 17:09:28.413 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button[data-testid='submit-button']]
2020-07-23 17:09:43.180 [main] INFO Expedia - The text "Tue, 29 Dec" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: th.depart-date.selected]
2020-07-23 17:09:43.188 [main] INFO Expedia - Highlighting the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: th.depart-date.selected]
2020-07-23 17:09:43.298 [main] INFO Expedia - Capturing screenshot of the visible area and saving at path - E:\Testing\WebTesting\WebTesting\screenshots\23-Jul-20\05.08 PM\oneWayFlight_checkEconomyClassResultsDefaultDate\Dataset1_SS2.jpg
2020-07-23 17:09:43.900 [main] INFO Expedia - oneWayFlight_checkEconomyClassResultsDefaultDate PASSED with parameters {Leaving from=Mumbai, Going to=Chennai, Departure Date=29/12/20, Travel Class=Economy, Adults=2.0, Children=1.0, Infants=1.0}
2020-07-23 17:09:43.903 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:09:43.904 [main] INFO Expedia - |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>>>>>>>>>>>>>>>>>ENDING TEST<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|
2020-07-23 17:09:43.905 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:09:43.907 [main] INFO Expedia - Deleting all the cookies
2020-07-23 17:09:57.603 [main] INFO Expedia - Navigating to URL - https://www.expedia.co.in/
2020-07-23 17:10:02.192 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:10:02.194 [main] INFO Expedia - |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>>>>>>>>>>>>>>>>>STARTING TEST<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|
2020-07-23 17:10:02.195 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:10:02.197 [main] INFO Expedia - Starting Test execution for the test "oneWayFlight_checkEconomyClassResultsDefaultDate" with test data - {Leaving from=Bengaluru, Going to=Delhi, Departure Date=17/8/20, Travel Class=Economy, Adults=3.0, Children=1.0, Infants=2.0}
2020-07-23 17:10:02.677 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //span[text()='Flights']]
2020-07-23 17:10:05.273 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //span[text()='One-way']]
2020-07-23 17:10:06.514 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: [data-stid='location-field-leg1-origin-menu-trigger']]
2020-07-23 17:10:07.198 [main] INFO Expedia - Sending text "Bengaluru" to the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: location-field-leg1-origin]
2020-07-23 17:10:08.986 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //strong[contains(text(),'Bengaluru')]]
2020-07-23 17:10:09.753 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: [data-stid='location-field-leg1-destination-menu-trigger']]
2020-07-23 17:10:10.446 [main] INFO Expedia - Sending text "Delhi" to the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: location-field-leg1-destination]
2020-07-23 17:10:12.128 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //strong[contains(text(),'Delhi')]]
2020-07-23 17:10:12.400 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: d1-btn]
2020-07-23 17:10:13.227 [main] INFO Expedia - Scrolling the page to bring the object "[[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker]" in the visible area
2020-07-23 17:10:14.637 [main] INFO Expedia - The text "July 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:10:14.675 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button.uitk-button.uitk-button-small.uitk-flex-item.uitk-button-paging:last-child]
2020-07-23 17:10:14.888 [main] INFO Expedia - The text "August 2020" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: div.uitk-new-date-picker-month:first-child h2]
2020-07-23 17:10:14.941 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //div[@class='uitk-new-date-picker-month'][1]//button[@data-day='17']]
2020-07-23 17:10:15.088 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button[data-stid='apply-date-picker'] > span]
2020-07-23 17:10:15.244 [main] INFO Expedia - Scrolling to the page top in one-go
2020-07-23 17:10:15.331 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: preferred-class-input-trigger]
2020-07-23 17:10:16.080 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //a[@class='uitk-list-item' and contains(text(),'Economy')]]
2020-07-23 17:10:16.246 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: a[data-testid='travelers-field']]
2020-07-23 17:10:17.200 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: adult-input-0]
2020-07-23 17:10:17.238 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='adult-input-0']/following-sibling::button]
2020-07-23 17:10:17.381 [main] INFO Expedia - The value of the attribute("value") is "2" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: adult-input-0]
2020-07-23 17:10:17.420 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='adult-input-0']/following-sibling::button]
2020-07-23 17:10:17.493 [main] INFO Expedia - The value of the attribute("value") is "3" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: adult-input-0]
2020-07-23 17:10:17.544 [main] INFO Expedia - The value of the attribute("value") is "0" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: child-input-0]
2020-07-23 17:10:17.680 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='child-input-0']/following-sibling::button]
2020-07-23 17:10:17.928 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: child-input-0]
2020-07-23 17:10:17.983 [main] INFO Expedia - The value of the attribute("value") is "0" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: infant-input-0]
2020-07-23 17:10:18.048 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='infant-input-0']/following-sibling::button]
2020-07-23 17:10:18.190 [main] INFO Expedia - The value of the attribute("value") is "1" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: infant-input-0]
2020-07-23 17:10:18.240 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //input[@id='infant-input-0']/following-sibling::button]
2020-07-23 17:10:18.329 [main] INFO Expedia - The value of the attribute("value") is "2" for the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> id: infant-input-0]
2020-07-23 17:10:18.375 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> xpath: //button[contains(text(),'Done')]]
2020-07-23 17:10:18.749 [main] INFO Expedia - Capturing screenshot of the visible area and saving at path - E:\Testing\WebTesting\WebTesting\screenshots\23-Jul-20\05.08 PM\oneWayFlight_checkEconomyClassResultsDefaultDate\Dataset2_SS1.jpg
2020-07-23 17:10:19.549 [main] INFO Expedia - Clicking on the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: button[data-testid='submit-button']]
2020-07-23 17:10:24.950 [main] INFO Expedia - The text "Mon, 17 Aug" was fetched from the object [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: th.depart-date.selected]
2020-07-23 17:10:24.954 [main] INFO Expedia - Highlighting the object - [[ChromeDriver: chrome on WINDOWS (e6d90b3b9c443edc5ce4b7226f26c405)] -> css selector: th.depart-date.selected]
2020-07-23 17:10:25.147 [main] INFO Expedia - Capturing screenshot of the visible area and saving at path - E:\Testing\WebTesting\WebTesting\screenshots\23-Jul-20\05.08 PM\oneWayFlight_checkEconomyClassResultsDefaultDate\Dataset2_SS2.jpg
2020-07-23 17:10:30.422 [main] INFO Expedia - oneWayFlight_checkEconomyClassResultsDefaultDate PASSED with parameters {Leaving from=Bengaluru, Going to=Delhi, Departure Date=17/8/20, Travel Class=Economy, Adults=3.0, Children=1.0, Infants=2.0}
2020-07-23 17:10:30.423 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:10:30.423 [main] INFO Expedia - |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>>>>>>>>>>>>>>>>>ENDING TEST<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|
2020-07-23 17:10:30.424 [main] INFO Expedia - |******************************************************************************************************************|
2020-07-23 17:10:30.488 [main] INFO Expedia - Closing all the windows/tabs opened by the WebDriver
2020-07-23 17:10:31.598 [main] INFO Expedia - Suite execution completed
答案1
得分: 1
配置中有一个名为“ThresholdFilter”的部分,它“触发”发送电子邮件。如果收到级别为ERROR的日志消息,将导致发送电子邮件。
从问题中不清楚操作员(OP)想要什么替代触发器。
如果应该在收到级别为WARN的日志消息时发送电子邮件,只需重新配置过滤器为<ThresholdFilter level="warn" onMatch="NEUTRAL" onMismatch="DENY" />
。
如果其他事情应该触发发送电子邮件(无论日志消息的级别如何),那么您可以配置一个查找日志消息该方面的不同过滤器。Log4j2有许多内置过滤器,可以配置为触发发送电子邮件。如果这些都不符合您的要求,您可以创建自定义过滤器。
因此,首先澄清自己希望触发的内容,然后配置或创建一个接受/对这种日志事件中立的过滤器,并拒绝不满足触发器要求的日志事件。
英文:
The configuration has a ThresholdFilter
that "triggers" the sending of email. If a log message with level ERROR was received, that results in an email being sent.
It is not clear to me from the question what the OP wants as the replacement trigger.
If an email should be sent whenever a log message with level WARN was received, simply reconfigure the filter to <ThresholdFilter level="warn" onMatch="NEUTRAL" onMismatch="DENY" />
.
If something else should trigger the sending of email (regardless of the level of the log message), then you can configure a different filter that looks for that aspect of the log message. Log4j2 has many built-in filters, and any of these can be configured to trigger sending email. If none of these meet your requirements, you can create a custom filter.
So, first clarify to yourself what should be the trigger, then configure or create a filter that accepts/is neutral to such log events and denies log events that do not meet the trigger requirement.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论