 <p>Since you're asking for the best way, and if Log4J is not a strong requirement, my suggestion would be to use <a href="http://logback.qos.ch/" rel="nofollow noreferrer">Logback</a> and its <a href="http://logback.qos.ch/manual/appenders.html#DBAppender" rel="nofollow noreferrer"><code>DbAppender</code></a>. That's the best way :)</p> <p>Last time I checked, the <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/jdbc/JDBCAppender.html" rel="nofollow noreferrer"><code>JDBCAppender</code></a> from Log4J was still not satisfying and if you can't use logback, you might prefer some third party implementation. See the links below for details:</p> <ul> <li><a href="http://www.boky.cc/2010/02/03/jdbcappender-for-log4j/" rel="nofollow noreferrer">http://www.boky.cc/2010/02/03/jdbcappender-for-log4j/</a></li> <li><a href="http://www.dankomannhaupt.de/projects/" rel="nofollow noreferrer">http://www.dankomannhaupt.de/projects/</a> (older)</li> </ul>