Is this a good thing to do; to log via a method like this?
public static void log(final Object... messages) {
logger.info(Joiner.on(',').useForNull("null").join(messages));
}
// Where in other parts of code we can call the logger method using commas instead of string concatenation. Please note Joiner is a guava class.
log(" Check ",obja.getXXX(),anotherObject.getMethod());
Expectation is clean code, convenience and performance.
Java Math log() method with example There are various cases : If the argument is NaN or less than zero, then the result is NaN. If the argument is positive infinity, then the result is positive infinity. If the argument is positive zero or negative zero, then the result is negative infinity.
One of the most popular solutions for the Java world is the Apache Log4j 2 framework. Maintained by the Apache Foundation, Log4j 2 is an improvement on the original Log4j, which was the most popular logging framework in Java for many years.
The Logging APIs capture information such as security failures, configuration errors, performance bottlenecks, and/or bugs in the application or platform. The core package includes support for delivering plain text or XML-formatted log records to memory, output streams, consoles, files, and sockets.
I use SLF4J's Logger
interface (with Logback implementation), which I find much cleaner to read.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Test {
private static final Logger logger = LoggerFactory.getLogger(Test.class);
public void method(String name, int age, Address address) {
logger.info("Person {}, age {} years old resides at {}", name, age, address);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With