How to read and copy the HTTP servlet response output stream content for logging

You need to create a Filter wherein you wrap the ServletResponse argument with a custom HttpServletResponseWrapper implementation wherein you override the getOutputStream() and getWriter() to return a custom ServletOutputStream implementation wherein you copy the written byte(s) in the base abstract OutputStream#write(int b) method. Then, you pass the wrapped custom HttpServletResponseWrapper to the FilterChain#doFilter() call instead … Read more

Spring Boot – How to log all requests and responses with exceptions in single place?

Don’t write any Interceptors, Filters, Components, Aspects, etc., this is a very common problem and has been solved many times over. Spring Boot has a modules called Actuator, which provides HTTP request logging out of the box. There’s an endpoint mapped to /trace (SB1.x) or /actuator/httptrace (SB2.0+) which will show you last 100 HTTP requests. … Read more

How do I enable/disable log levels in Android?

The Android Documentation says the following about Log Levels: Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept. So you may want to consider stripping the log Verbose logging statements out, possibly using ProGuard as suggested … Read more

Log all queries in mysql

(Note: For mysql-5.6+ this won’t work. There’s a solution that applies to mysql-5.6+ if you scroll down or click here.) If you don’t want or cannot restart the MySQL server you can proceed like this on your running server: Create your log tables on the mysql database CREATE TABLE `slow_log` ( `start_time` timestamp NOT NULL … Read more

How to log PostgreSQL queries?

In your data/postgresql.conf file, change the log_statement setting to ‘all’. Edit Looking at your new information, I’d say there may be a few other settings to verify: make sure you have turned on the log_destination variable make sure you turn on the logging_collector also make sure that the log_directory directory already exists inside of the … Read more

How to enable MySQL Query Log?

First, Remember that this logfile can grow very large on a busy server. For mysql < 5.1.29: To enable the query log, put this in /etc/my.cnf in the [mysqld] section log = /path/to/query.log #works for mysql < 5.1.29 Also, to enable it from MySQL console SET general_log = 1; See http://dev.mysql.com/doc/refman/5.1/en/query-log.html For mysql 5.1.29+ With … Read more

How to show the last queries executed on MySQL?

For those blessed with MySQL >= 5.1.12, you can control this option globally at runtime: Execute SET GLOBAL log_output=”TABLE”; Execute SET GLOBAL general_log = ‘ON’; Take a look at the table mysql.general_log If you prefer to output to a file instead of a table: SET GLOBAL log_output = “FILE”; the default. SET GLOBAL general_log_file = … Read more