Get email with execution log even when no error exists
Asked Answered
S

1

0

My requirements:

  1. 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.
  2. 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">[email protected]</Property>
        <Property name="sender">[email protected]</Property>
        <Property name="host">smtp.gmail.com</Property>
        <Property name="port">587</Property>
        <Property name="username">[email protected]</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
Shroff answered 22/7, 2020 at 22:22 Comment(0)
P
1

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.

Petulancy answered 22/7, 2020 at 23:7 Comment(1)
Thanks for pointing me in the right direction. The links were helpful. I ended up using the composite filters in the end which satisfy both my requirements now. I will accept this answer and post my solution as an edit in the questionShroff

© 2022 - 2024 — McMap. All rights reserved.