I think I invented this extra stuff back when I was co-writing a proprietary, complex, and feature-rich JDBC driver. I no longer live in that particular code base, but I can say that writing this kind of code and implementing a specification like JDBC makes you write code to a logging library rather differently from anything else. You want a logging API that is rich, expressive, and efficient. Log4j 2 is all of that.
For the curious: We only log using DEBUG and TRACE. We want to focus on using TRACE for APIs and wire-level data. This leaves DEBUG for everything else, and then we use markers. I toyed with the idea of adding a custom WIRE level that would be finer than TRACE but never pulled the trigger on that. Gary On Tue, Feb 13, 2024 at 7:09 AM Apache <ralph.go...@dslextreme.com> wrote: > > Yes, add the missing method. > > We use these methods A LOT. I suspect we are not alone. > > Ralph > > > On Feb 13, 2024, at 3:17 AM, Piotr P. Karwasz <piotr.karw...@gmail.com> > > wrote: > > > > Hi all, > > > > Our Logger interface contains 11 traceEntry/traceExit methods and 4 > > deprecated entry/exit methods. As far as I have seen, only the > > deprecated ones are documented in [1]. > > > > I understand the purpose of some of them: > > > > * entry(Object...) and its vararg-free version entry() can be used to > > log the parameters of a method call, > > * why is there not traceEntry(Object...) non-deprecated method? > > * exit(R), exit(), traceExit(R) and traceExit() log the return value > > of a method call. > > > > For those that want to be creative, you can add a custom format > > specifier, so we have > > > > * traceEntry(String, Object...) for input parameters, > > * traceExit(String, R) for the return value, > > * there is no traceExit(String) variant for methods returning void. > > > > If someone wants the exit message to cite parameters again, you can > > use `traceExit(EntryMessage, R)` or `traceExit(EntryMessage)`. > > > > However these seem pretty much useless to me: > > > > * traceEntry(Supplier...), traceEntry(String, Supplier...) seem like > > overkill, since you usually log parameters that are already evaluated, > > * traceEntry(Message) and traceExit(Message, R) seem also overkill to > > me: if the user is not satisfied with providing a format specifier, he > > can call trace(Message) or trace(Supplier) with the message of his > > choice. > > > > Should we add the missing `traceEntry(Object...)` and `traceExit()` > > methods and deprecate those above? > > > > In general I don't see users today using those methods directly in > > their code. If they use them, they probably use AspectJ or a similar > > framework to decorate the messages. In such a case they probably use 2 > > methods of the 15 above. > > > > Piotr > > > > [1] https://logging.apache.org/log4j/2.x/manual/messages.html >