All Projects → candrews → Log4jdbc Spring Boot Starter

candrews / Log4jdbc Spring Boot Starter

Licence: apache-2.0
Starter for using Log4jdbc with Spring Boot

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Log4jdbc Spring Boot Starter

Poli
An easy-to-use BI server built for SQL lovers. Power data analysis in SQL and gain faster business insights.
Stars: ✭ 1,850 (+3675.51%)
Mutual labels:  jdbc, spring-boot
Quickperf
QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties
Stars: ✭ 231 (+371.43%)
Mutual labels:  jdbc, spring-boot
Jplusone
Tool for automatic detection and asserting "N+1 SELECT problem" occurences in JPA based Spring Boot Java applications and finding origin of JPA issued SQL statements in general
Stars: ✭ 91 (+85.71%)
Mutual labels:  jdbc, spring-boot
Oauthserver
快速实现Spring Boot Oauth2授权服务,保护你的应用资源。
Stars: ✭ 238 (+385.71%)
Mutual labels:  jdbc, spring-boot
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+565.31%)
Mutual labels:  jdbc, spring-boot
Watchdog Framework
🍻 「停止维护」基于SpringBoot+Shiro+Mybatis等开发的轻量级管理系统快速开发脚手架
Stars: ✭ 421 (+759.18%)
Mutual labels:  jdbc, spring-boot
Java Specialagent
Automatic instrumentation for 3rd-party libraries in Java applications with OpenTracing.
Stars: ✭ 156 (+218.37%)
Mutual labels:  jdbc, spring-boot
Sqlhelper
SQL Tools ( Dialect, Pagination, DDL dump, UrlParser, SqlStatementParser, WallFilter, BatchExecutor for Test) based Java. it is easy to integration into any ORM frameworks
Stars: ✭ 242 (+393.88%)
Mutual labels:  jdbc, spring-boot
Spring Boot Data Source Decorator
Spring Boot integration with p6spy, datasource-proxy, flexy-pool and spring-cloud-sleuth
Stars: ✭ 295 (+502.04%)
Mutual labels:  jdbc, spring-boot
Db Scheduler
Persistent cluster-friendly scheduler for Java
Stars: ✭ 352 (+618.37%)
Mutual labels:  jdbc, spring-boot
Hibernate Springboot
Collection of best practices for Java persistence performance in Spring Boot applications
Stars: ✭ 589 (+1102.04%)
Mutual labels:  jdbc, spring-boot
Spring Cloud Study
开源书《跟我学Spring Cloud》的配套代码。讨论QQ群:731548893
Stars: ✭ 1,036 (+2014.29%)
Mutual labels:  spring-boot
Spring Boot Microservice Eureka Zuul Docker
Spring-Boot rest microservices using Eureka, Zuul, Docker. Monitoring with logstash, logback, elasticsearch, kibana
Stars: ✭ 45 (-8.16%)
Mutual labels:  spring-boot
Mini Platform
Mini-Platform致力于更简洁易用的轻量级微服务治理平台。
Stars: ✭ 45 (-8.16%)
Mutual labels:  spring-boot
Sentiment Analysis Twitter Microservices Example
A sample application that demonstrates how to build a graph processing platform to analyze sources of emotional influence on Twitter.
Stars: ✭ 45 (-8.16%)
Mutual labels:  spring-boot
Flips
Repository for feature flip library which provides various annotations to flip any feature. Works with Java8, Spring, Spring Boot
Stars: ✭ 48 (-2.04%)
Mutual labels:  spring-boot
Weather
一个天气查询服务:爬取数据、Web服务、小程序展示
Stars: ✭ 46 (-6.12%)
Mutual labels:  spring-boot
Spring Boot React
Isomorphic React app with Spring Boot
Stars: ✭ 44 (-10.2%)
Mutual labels:  spring-boot
Disconf Spring Boot Starter
disconf-spring-boot-starter 让你可以使用spring-boot的方式开发依赖disconf的程序 只需要关心disconfi的配置文件和配置项,省略了编写xml的麻烦
Stars: ✭ 44 (-10.2%)
Mutual labels:  spring-boot
Ssh Shell Spring Boot
Spring shell in spring boot application over ssh
Stars: ✭ 43 (-12.24%)
Mutual labels:  spring-boot

Log4jdbc Spring Boot Starter

DevOps By Rultor.com Build Status Maven Central Reference Status Dependency Status Javadoc

The Log4jdbc Spring Boot Starter facilitates the quick and easy use of log4jdbc in Spring Boot projects.

Log4jdbc is particularly handy as it can log SQL that is ready to run. Instead of logging SQL with '?' where parameter values need to be inserted (like, for example, what spring.jpa.properties.hibernate.show_sql=true does), log4jdbc can log SQL with those place holders substituted with their actual values. So instead of select name from User where id = ? the log will say select name from User where id = 5.

Quick Start

  • Minimum requirements — You'll need Java 1.8+ and Spring Boot 2.1+.
  • Download — Depend on this library using, for example, Maven:
  <dependency>
    <groupId>com.integralblue</groupId>
    <artifactId>log4jdbc-spring-boot-starter</artifactId>
    <version>[INSERT VERSION HERE]</version>
  </dependency>
  • Configure — In application.properties, enable a logger (for example, logging.level.jdbc.sqlonly=ERROR). See Loggers for details.

Configuration

Use application.properties to configure log4jdbc. There is Spring configuration meta-data for IDE autocompletion; see spring-configuration-metadata.json. Supported settings are:

property default description
log4jdbc.drivers One or more fully qualified class names for JDBC drivers that log4jdbc should load and wrap. If more than one driver needs to be specified here, they should be comma separated with no spaces. This option is not normally needed because most popular JDBC drivers are already loaded by default. This should be used if one or more additional JDBC drivers that (log4jdbc doesn't already wrap) needs to be included.
log4jdbc.auto.load.popular.drivers true Set this to false to disable the feature where popular drivers are automatically loaded. If this is false, you must set the log4jdbc.drivers property in order to load the driver(s) you want.
log4jdbc.debug.stack.prefix A REGEX matching the package name of your application. The call stack will be searched down to the first occurrence of a class that has the matching REGEX. If this is not set, the actual class that called into log4jdbc is used in the debug output (in many cases this will be a connection pool class). For example, setting a system property such as this: -Dlog4jdbc.debug.stack.prefix=^com\.mycompany\.myapp.* would cause the call stack to be searched for the first call that came from code in the com.mycompany.myapp package or below, thus if all of your sql generating code was in code located in the com.mycompany.myapp package or any subpackages, this would be printed in the debug information, rather than the package name for a connection pool, object relational system, etc. Please note that the behavior of this property has changed as compared to the standard log4jdbc implementation. This property is now a REGEX, instead of being just the package prefix of the stack trace. So, for instance, if you want to target the prefix org.mypackage, the value of this property should be: ^org\.mypackage.*.
log4jdbc.sqltiming.warn.threshold Millisecond time value. Causes SQL that takes the number of milliseconds specified or more time to execute to be logged at the warning level in the sqltiming log. Note that the sqltiming log must be enabled at the warn log level for this feature to work. Also the logged output for this setting will log with debug information that is normally only shown when the sqltiming log is enabled at the debug level. This can help you to more quickly find slower running SQL without adding overhead or logging for normal running SQL that executes below the threshold level (if the logging level is set appropriately).
log4jdbc.sqltiming.error.threshold Millisecond time value. Causes SQL that takes the number of milliseconds specified or more time to execute to be logged at the error level in the sqltiming log. Note that the sqltiming log must be enabled at the error log level for this feature to work. Also the logged output for this setting will log with debug information that is normally only shown when the sqltiming log is enabled at the debug level. This can help you to more quickly find slower running SQL without adding overhead or logging for normal running SQL that executes below the threshold level (if the logging level is set appropriately).
log4jdbc.dump.booleanastruefalse false When dumping boolean values in SQL, dump them as 'true' or 'false'. If this option is not set, they will be dumped as 1 or 0 as many databases do not have a boolean type, and this allows for more portable sql dumping.
log4jdbc.dump.sql.maxlinelength 90 When dumping SQL, if this is greater than 0, than the dumped SQL will be broken up into lines that are no longer than this value. Set this value to 0 if you don't want log4jdbc to try and break the SQL into lines this way. In future versions of log4jdbc, this will probably default to 0.
log4jdbc.dump.fulldebugstacktrace false If dumping in debug mode, dump the full stack trace. This will result in EXTREMELY voluminous output, but can be very useful under some circumstances when trying to track down the call chain for generated SQL.
log4jdbc.dump.sql.select true Set this to false to suppress SQL select statements in the output. Note that if you use the Log4j 2 logger, it is also possible to control select statements output via the marker LOG4JDBC_SELECT (see section "Disabling some SQL operations, or dispatching them in different files"). The use of this property prepend the use of the marker.
log4jdbc.dump.sql.insert true Set this to false to suppress SQL insert statements in the output. Note that if you use the Log4j 2 logger, it is also possible to control insert statements output via the marker LOG4JDBC_INSERT (see section "Disabling some SQL operations, or dispatching them in different files"). The use of this property prepend the use of the marker.
log4jdbc.dump.sql.update true Set this to false to suppress SQL update statements in the output. Note that if you use the Log4j 2 logger, it is also possible to control update statements output via the marker LOG4JDBC_UPDATE (see section "Disabling some SQL operations, or dispatching them in different files"). The use of this property prepend the use of the marker.
log4jdbc.dump.sql.delete true Set this to false to suppress SQL delete statements in the output. Note that if you use the Log4j 2 logger, it is also possible to control delete statements output via the marker LOG4JDBC_DELETE (see section "Disabling some SQL operations, or dispatching them in different files"). The use of this property prepend the use of the marker.
log4jdbc.dump.sql.create true Set this to false to suppress SQL create statements in the output. Note that if you use the Log4j 2 logger, it is also possible to control create statements output via the marker LOG4JDBC_CREATE (see section "Disabling some SQL operations, or dispatching them in different files"). The use of this property prepend the use of the marker.
log4jdbc.dump.sql.addsemicolon false Set this to true to add an extra semicolon to the end of SQL in the output. This can be useful when you want to generate SQL from a program with log4jdbc in order to create a script to feed back into a database to run at a later time.
log4jdbc.spylogdelegator.name net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator The qualified class name of the SpyLogDelegator to use. Note that if you want to use log4jdbc-log4j2 with Log4j 2 rather than SLF4J, you must set this property to: net.sf.log4jdbc.log.log4j2.Log4j2SpyLogDelegator. Note that the default in this Starter is to use SLF4J which is different from the log4jdbc library's default.
log4jdbc.statement.warn false Set this to true to display warnings (Why would you care?) in the log when Statements are used in the log.
log4jdbc.trim.sql true Set this to false to not trim the logged SQL.
log4jdbc.trim.sql.extrablanklines true Set this to false to not trim extra blank lines in the logged SQL (by default, when more than one blank line in a row occurs, the contiguous lines are collapsed to just one blank line).
log4jdbc.suppress.generated.keys.exception false Set to true to ignore any exception produced by the method Statement.getGeneratedKeys()
log4jdbc.log4j2.properties.file log4jdbc.log4j2.properties Set the name of the property file to use

Loggers

Note that, by default, nothing will be logged. In fact, if all the loggers are disabled (which is the default), then log4jdbc doesn't even wrap the java.sql.Connection returned by javax.sql.DataSource.getConnection() (which is useful for production configurations).

logger description
jdbc.sqlonly Logs only SQL. SQL executed within a prepared statement is automatically shown with it's bind arguments replaced with the data bound at that position, for greatly increased readability.
jdbc.sqltiming Logs the SQL, post-execution, including timing statistics on how long the SQL took to execute.
jdbc.audit Logs ALL JDBC calls except for ResultSets. This is a very voluminous output, and is not normally needed unless tracking down a specific JDBC problem.
jdbc.resultset Even more voluminous, because all calls to ResultSet objects are logged.
jdbc.resultsettable Log the jdbc results as a table. Level debug will fill in unread values in the result set.
jdbc.connection Logs connection open and close events as well as dumping all open connection numbers. This is very useful for hunting down connection leak problems.

To set a logger's level, use application.properties in the same way any other log level is configured (see the Spring Boot Logging Guide for reference). For example, logging.level.jdbc.sqlonly=DEBUG

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].