Logging and Error Handling

The {@link oajr.RestContext#REST_logger} property allows you to configure logging for your resource.
The interface is shown below:

- {@link oajr.RestLogger}
  - {@link oajr.RestLogger#log(Level,String,Object[]) log(Level,String,Object[])}
  - {@link oajr.RestLogger#log(Level,Throwable,String,Object[]) log(Level,Throwable,String,Object[])}
  - {@link oajr.RestLogger#logObjects(Level,String,Object[]) logObjects(Level,String,Object[])}
  - {@link oajr.RestLogger#onError(HttpServletRequest,HttpServletResponse,RestException) onError(HttpServletRequest,HttpServletResponse,RestException)}
    Gets called when an error occurs on a request call.
    Default implementation logs the error.

The {@link oajr.RestLogger#logObjects(Level,String,Object[]) logObjects()} method is particularly useful because it allows you to pass in POJOs as arguments that serialized using {@link oaj.json.SimpleJsonSerializer#DEFAULT_READABLE}, but only if the message is actually logged.

##### Example:

logger.logObjects(DEBUG, "Pojo contents:\n{0}", myPojo);

By default, the Juneau framework uses the built-in Java Logging API for logging.
But you can define your own implementation to use any framework you wish.

The {@link oajr.RestLogger} instance is accessible via the following:

- {@link oajr.RestContext#getLogger()}
- {@link oajr.RestRequest#getLogger()}

In addition, the logger can be accessed by passing it as a parameter to your REST java method:

@RestMethod() public Object doSomething(RestLogger logger) {...}

If your resource extends from {@link oajr.RestServlet}, you can also use and override the following methods:

- {@link oajr.RestServlet#log(Level,String,Object...)}
- {@link oajr.RestServlet#log(Level,Throwable,String,Object...)}