In java development, how can I refer to a class or method name in a log statement without hard-coding it?

I want to have a set of standard logging statements on all classes, methods and functions. It should figure out what class it is in, rather than rely on the developer to do something like "Entering class sendMessage()". Seems like a pretty straightforward scenario, but I can’t seem to find a solution.

you can use this.getClass() method to do this

This entry was posted in class development. Bookmark the permalink.

One Response to In java development, how can I refer to a class or method name in a log statement without hard-coding it?

  1. Karthik says:

    you can use this.getClass() method to do this
    References :