Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting an error while installing #110

Open
MucahitZengin opened this issue Jan 1, 2024 · 0 comments
Open

I'm getting an error while installing #110

MucahitZengin opened this issue Jan 1, 2024 · 0 comments

Comments

@MucahitZengin
Copy link

When I try to install it with Maven, it gives the following error:

[ERROR] Failures:
[ERROR] NumberOfLogStatementsTest.testCountLog4JHelloWorldFile:31 expected: <7> but was: <6>

The 31st line mentioned is here:

28 @Test
29 public void testCountLog4JHelloWorldFile() {
30 CKClassResult a = report.get("logs.Log4JHelloWorld");
31 assertEquals(7, a.getNumberOfLogStatements());
32 }

The Log4JHelloWorld class is like this:

public class Log4JHelloWorld {
     private static final Logger logger = LogManager.getLogger("HelloWorld");
     public static void main(String[] args) {
         logger.info("Hello, World!");
         if (logger.isDebugEnabled()) {
             logger.debug("Logging in user " + user.getName() + " with birthday " + user.getBirthdayCalendar());
         }
         logger.debug("Logging in user {} with birthday {}", user.getName(), user.getBirthdayCalendar());

         // Java-8 style optimization: no need to explicitly check the log level:
         // the lambda expression is not evaluated if the TRACE level is not enabled
         logger.trace("Some long-running operation returned {}", () -> expensiveOperation());

         // pre-Java 8 style optimization: explicitly check the log level
         // to make sure the expensiveOperation() method is only called if necessary
         if (logger.isTraceEnabled()) {
             logger.trace("Some long-running operation returned {}", expensiveOperation());
         }

         // Fluent API/Builder Pattern
         logger.atError().withThrowable(exception).log("Unable to process request due to {}", code);
         logger.atInfo().withMarker(marker).withLocation().withThrowable(exception).log("Login for user {} failed", userId);
     }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant