Home » Tag Archives: Logging

Tag Archives: Logging

Java 8 Deferred Invocation with Java Util Logging

java-logo

In the blog post Better Performing Non-Logging Logger Calls in Log4j2, I looked at approaches one can use in Log4j 2 to reduce or avoid invocation of methods in log statements that, based on the specified log level, are not actually logged at all. As part of this discussion, I covered Log4j 2‘s support for Java 8-based deferred execution using ...

Read More »

The 5 Java logging rules

java-logo

Logging is a critical factor that should be always kept into account during the software development. When something bad happens in production, the log files are usually the starting point of our fault analysis. And, often, they are the only information in our hands to understand what is happened and which is the root cause of the problem. It is ...

Read More »

Tutorial: logging during tests

slf4j-logo

Logging is a popular solution to show what the software is doing while it is running. But what happens to the logging when we are unit testing our application with jUnit/TestNG ? During the automated tests execution, we are usually not interested to see the logging messages because our main interest is the test results. It would be nice to ...

Read More »

Simplify your logging with tinylog 1.0

apache-log4j-logo

With a size of only 75 KB, tinylog is a lightweight alternative to the widespread classical logging frameworks Log4j and Logback. The final version 1.0 has been just released at the end of March, after three years of development. In several design issues, tinylog takes a deliberately different approach from classical logging frameworks in Java. This article will show the ...

Read More »

OptaPlanner – How fast is logging?

software-development-2-logo

What’s the cost of trace/debug logging in production? What’s the performance cost of logging to a file? In these benchmarks, I compare the performance impact of logging levels (error, warn, info, debug, trace) and logging appenders (console appender, file appender) on several realistic OptaPlanner use cases. Benchmark methodology Logging implementation: SFL4J 1.7.2 with Logback 1.0.9 (Logback is the spiritual successor ...

Read More »

Using Java 8 to Prevent Excessively Wide Logs

java-logo

Some logs are there to be consumed by machines and kept forever. Other logs are there just to debug and to be consumed by humans. In the latter case, you often want to make sure that you don’t produce too much logs, especially not too wide logs, as many editors and other tools have problems once line lenghts exceed a ...

Read More »

Writing your own logging service?

software-development-2-logo

Application logging is one those things like favorite Editors war: everyone has their own opinions and there are endless of implemenations and flavors out there. Now a days, you likely would want to use something already available such as Log4j or Logback. Even JDK has a built in “java.util.logging” implementation. To avoid couple to a direct logger, many projects would ...

Read More »

Java Method Logging with AOP and Annotations

java-interview-questions-answers

Sometimes, I want to log (through slf4j and log4j) every execution of a method, seeing what arguments it receives, what it returns and how much time every execution takes. This is how I’m doing it, with help of AspectJ, jcabi-aspects and Java 6 annotations:                 public class Foo { @Loggable public int power(int ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns