nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff <>
Subject Re: How does logging level get set?
Date Wed, 26 Sep 2018 14:54:44 GMT
One point for using the isDebugEnabled (or any of the other level-checking
methods) is that if, in the values being logged, there is string
concatenation happening in the log.{level} statement itself. The cost of
that is paid whether the level is enabled or not.  Even with parameterized
logging, if the log.{level} call is passed a method invocation as a
parameter, the cost is paid there as well, as Kevin mentioned.

The best rule of thumb, IMO, is to use the enabled check if a parameter or
result of string concatenation with something being logged will cause
computation that is "expensive", such as sorting a list, especially if the
logging would be invoked iteratively.  If there's a loop that executes with
"many iterations", but has debug logging that is doing string
concatenation, that would be a good scenario to use the enabled check,
though parameterization with literal values helps in that case. If the
value you are using in a logging call comes from a getter which retrieves
something that's in a literal form, like a getter that returns a boolean
variable, that would be inexpensive.  Calling some list.size() methods are
also pretty cheap.  Even "cheap" operations can add up if the logging is
done iteratively.

Adding a lot of isDebugEnabled checks can make the code less readable and
add many extra lines of code.  Those checks might be necessary to prevent a
decrease in performance, though.  You can always run a profiler to see how
much time you can save when a particular logging level is not enabled, and
update the code with enabled checks as necessary.

On Thu, Sep 20, 2018 at 3:37 PM Mohammed Nadeem <>

> Hi,
> To answer to your question, Nifi has a context logger which is mapped to
> logback.xml file. Generally INFO level of log is defaulted in
> nifi-app.logs.
> In your code, you can simple use getLogger().debug("your message") or INFO,
> ERROR,WARN etc to enable the logging into nifi-app.log with component-id
> etc.
> As I mentioned, by default INFO level would go to nifi-app.logs, you can
> change the level in logback.xml under root.
> Thanks & Regards,
> Nadeem
> --
> Sent from:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message