3

At the moment my exceptions are logging text and stack-trace:

throw new RequestValidationException("test exception", parameters, e);

I want to Collect all parameters for the throws exception in all methods.

HashMap<String, String> parameters = new HashMap<String, String>();   
        parameters.put("testparam", message.toString());

throw new RequestValidationException("test exception", parameters, e);

Now i'm using a hashmap. I have to look at every method and check if it's using a parameter. This will cost me days. There are like thousands of exceptions in the code, is there a simple way to show the values?

2
  • 1
    Do you mean something automatic, or are you asking for a way to create a message that contains parameter values? Commented Jun 18, 2015 at 13:47
  • It's a little unclear to me what you're trying to accomplish. Could you provide some pseudo-code that illustrates the behavior you're looking for? Commented Jun 18, 2015 at 13:49

1 Answer 1

2

You can use slf4j-ext for logging method parameters. They are logged at the trace level.

private static final XLogger xlogger = XLoggerFactory.getXLogger(MyClass.class);

Then you can use at start and end of your methods like this:

protected void Method1(Message aMessage){
    xLogger.entry(aMessage);
    ...
    xLogger.exit();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.