Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7888533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:51:21+00:00 2026-06-03T05:51:21+00:00

I will try to explain what I’m trying to accomplish as clear as I

  • 0

I will try to explain what I’m trying to accomplish as clear as I can.

I’m writing the back end of a web application, that uses REST APIs for extracting data that is used for reports in the client side.
The framework I’m writing on uses Codehaus jackson for parsing the requests from JSON to data objects (data beans).
I have a bunch of APIs of this sort, 10-15.
each of them gets a different request object from the client side (though some inheritance do exist).
what I want to do is add logging (using log4j) for each of these APIs so that when I enter each of the methods the request data object will be logged.
the simple solution would be to implement a toString() method for each of these data objects, but I want to avoid going over all of these data objects and see if there’s a solution similiar to the way that jackson parses the JSON into an object.
I.e have the object converted back to its textual format in order to put it into the log.

I assume there’s so easy way to do so.

This is an example of a REST API and its data bean:

@POST
@Path("/path123/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getSomeData(@Context HttpServletRequest httpServletRequest, DataBeanExample bean){
    DataBeanExample resultBean;
    //DO SOME STUFF , for example take the bean, extract parameters from it and call some other api.
    return Response.ok(resultBean, MediaType.APPLICATION_JSON).build();

}


@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "DataBeanExample")

public class DataBeanExample{

@XmlElement(name = "timeFrame", required = true)
private String timeFrame = "";
@XmlElement(name = "timeFrom",required = true)
private long timeFrom;
@XmlElement(name = "timeTo",required = true)
private long timeTo;

public String getTimeFrame() {
    return timeFrame;
}

public void setTimeFrame(String timeFrame) {
    this.timeFrame = timeFrame;
}

public long getTimeTo() {
    return timeTo;
}

public void setTimeTo(long timeTo) {
    this.timeTo = timeTo;
}

public long getTimeFrom() {
    return timeFrom;
}

public void setTimeFrom(long timeFrom) {
    this.timeFrom = timeFrom;
}

}

In the example, what I want to do is at the beginning of “getSomeData” take the object bean and have it logged.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:51:22+00:00Added an answer on June 3, 2026 at 5:51 am

    Probably this might work

    new ObjectMapper().writeValue(System.out, dataBeanExampleInstance)
    

    or writeValueAsString

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the post title wasn't clear, I will try to explain a little
I'm going to try to explain this best I can I will provide more
I will try to make this as clear as I can, but if you
I will try to explain this the best way I can, but feel free
I'm not a pro in web UI, so I will try to explain myself
Ok, I'm not sure that my title was clear enough, but I will try
I will try to explain as well as possible what I'm trying to do.
I will try to explain the problem that I have with this code. This
I will try and explain this the best way I can. I have a
Good day, i will try to explain my problem as best as i can.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.