logging - Create log method to log parameters and their values on current executing method in java -
i want have method - example logutil.logcurrentmethod()
, return parameters of method executed , values. example :
public void temp(int first, string second, int third){ logutil.logcurrentmethod() //something }
and when call :
temp(1, "2", 3);
to print:
first: 1 second: 2 third: 3
i want that, because annoying log parameters of methods 5 parameters example. logcurrentmethod
can take parameters, idea make logging easier. problem when copy paste log lines, don't change parameters names (so have example logged width , width instead of width , height or that). can create new object{}.getclass.getenclosingmethod()
method , pass method (and use reflection
take names), don't know values. other approach pass parameters log method , pass new object{}.getclass.getenclosingmethod()
, think there should easier , more convenient way.
in advance.
you can 2 ways-
by using interceptor-logging interceptors
also refer this-oracle doc interceptor
by using aspectj- logging aspectj
refer so answer know how use aspectj logging purpose.
Comments
Post a Comment