carterkozak commented on a change in pull request #284: LOG4J2-2639 - Allow
logging calls to be constructed using a builder pattern
URL: https://github.com/apache/logging-log4j2/pull/284#discussion_r296490927
##########
File path:
log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
##########
@@ -2734,4 +2748,108 @@ public void warn(final String message, final Object
p0, final Object p1, final O
final Object p7, final Object p8, final Object p9) {
logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5,
p6, p7, p8, p9);
}
+
+ /**
+ * Constuct a trace log event.
+ * @return a LogBuilder.
+ * @since 3.0
+ */
+ @Override
+ public LogBuilder atTrace() {
+ if (isTraceEnabled()) {
+ return logBuilder.get().setLevel(Level.TRACE);
Review comment:
I think we need something similar to `ReusableParameterizedMessage.reserved`
for this to work, otherwise we will clobber threadlocal state with something
like this:
```java
private void func() {
log.atInfo().withMessage("Value {}").withParameters(getValue()).log();
}
private Object getValue() {
log.atInfo().withMessage("Getting Value").log();
return value;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services