Tuesday, January 27, 2015

Why am I getting "WARNING arguments left: 1"

If you are new to Akka Logging and are used to using Log4j, there is a good chance you will get the error "WARNING arguments left: 1", and not know where its coming from.

So, here it is:
In log4j, you maybe used to writing:
logger.warn("Exception caught: ", e);

This is perfectly valid and works fine. If you use this line in akka logging, you will get the error "WARNING arguments left: 1" because in the case of logback, the syntax assumes it is filling in params from the string, so it expects this:
logger.warning("Exception caught: {}", e);
Hope this will help all of us (including me) not to get caught by this again....

10 comments:

  1. logger.error(e,"Exception caught");

    ReplyDelete
  2. Thank you, it is quite helpful

    ReplyDelete
  3. Agree with Unknown above, in most cases I think logger.error(e, "Problem doing X") is a better approach because your logging system can deal with the Exception directly, instead of just getting a toString version of the Exception (usually the message field). With an out of the box configuration this means you'll actually get the stack trace in the logs.

    ReplyDelete
  4. concise and very to the point. thanks.

    ReplyDelete