Cannot remove BrowserUpProxy logs from console using log4j2.xml config file

21 views Asked by At

I have a JAVA project using Maven, TestNG, and Selenium webdriver. This project mainly consist of automated UI tests and I implemented browserupproxy to record the HAR logs of each test. It works and I could record all the har logs of my tests.

However I faced this annoying issue where I cannot remove the browseruprpoxy logs from my console! This library spams my console to the point that I cannot read my console log anymore.

I have tried to turn off the logging of the specific library using log4j2.xml but I did not find any success. I also excluded any logging libraries I found in browserupproxy's own pom file. I also tried in log4j2.xml: Making ROOT level = OFF just to see what happens.

  • Console logs for my automation test do not appear but browser up console logs still appeared! Seems this library has its own logger? I am not too sure.

POM.xml contents:

logging libraries

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.11.2</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.11.2</version>
</dependency>

browserupproxy

        <dependency>
            <groupId>com.browserup</groupId>
            <artifactId>browserup-proxy-core</artifactId>
            <version>2.1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
    <Properties>
        <Property name="PATTERN_INFO">%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{0}:%L  - %msg%n</Property>
    </Properties>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="${PATTERN_INFO}"/>
        </Console>
        <File name="LogFile" fileName="console.log" append="false">
            <PatternLayout pattern="${PATTERN_INFO}"/>
        </File>
    </Appenders>
    <Loggers>
        <Logger name="com.browserup" level="off" additivity="false"/>
        <Root level="info" additivity="false">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="LogFile"/>
        </Root>
    </Loggers>
</Configuration>

Seems browserup does not respect my log4j2.xml file. Even when I set the logger for the browserup package to OFF.

0

There are 0 answers