public HttpServletRequestLoggingWrapper(final HttpServletRequest servletRequest, final int _maxDumpSizeInKB) {
        super(servletRequest);

        maxDumpSizeInKB = _maxDumpSizeInKB * 1000;
        buffer = new ByteArrayOutputStream(RequestLoggerFilter.BUFFER_SIZE);
        InputStream stream = null;
        try {
            stream = super.getInputStream();
            int n;
            while ((n = stream.read()) != -1) {
                buffer.write(n);
            }
        } catch (final IOException e) {
            logger.error("IO caught while dumping request", e);
            caughtExceptionOnRead = e;
        } finally {
            if(stream != null) {
                try {
                    stream.close();
                } catch (IOException e) {
                    logger.error("IO caught while closing input stream request", e);
                }
            }
        }


        inputStream = new ServletInputStream() {
            final ByteArrayInputStream stream = new ByteArrayInputStream(buffer.toByteArray());

            @Override
            public int read() throws IOException {
                return stream.read();
            }
        };
    }