Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxlevel3
minlevel2
typeflat
separatorpipe

Log SQL statements

Administrators can optionally log all SQL statements used in sql macros. This option is enabled by adding configuration in the ../WEB-INF/classes/log4j.properties file. In addition, warnings are issued when the default row limit is exceeded.

No Format
titleAdd to ../WEB-INF/classes/log4j.properties
# SQL statement logging
log4j.appender.sqlplugin=org.apache.log4j.RollingFileAppender
log4j.appender.sqlplugin.File=${catalina.home}/home/logs/sql-plugin.log
log4j.appender.sqlplugin.Threshold=INFO
log4j.appender.sqlplugin.MaxFileSize=20480KB
log4j.appender.sqlplugin.MaxBackupIndex=10
log4j.appender.sqlplugin.layout=com.atlassian.confluence.util.PatternLayoutWithContext
log4j.appender.sqlplugin.layout.ConversionPattern=%d %p %m%n

log4j.logger.org.swift.confluence.sql.SqlMacro.statement=INFO, sqlplugin
log4j.additivity.org.swift.confluence.sql.SqlMacro.statement=false

log4j.logger.org.swift.confluence.sql.SqlQueryMacro.statement=INFO, sqlplugin
log4j.additivity.org.swift.confluence.sql.SqlQueryMacro.statement=false

Add logging at runtime

  1. Go to Administration -> Logging and Profiling
  2. Find the Add new entry area
  3. Add INFO entries for the following: org.swift.confluence.sql.SqlMacro.statement and org.swift.confluence.sql.SqlQueryMacro.statement
  4. Log statements will appear in the standard confluence log file
  5. Logging will occur immediately, but only last until Confluence is restarted
Tip
titleUse logging when establishing or lowering row limit

Setting or lowering the row limit in an installation may cause a few existing SQL queries to show only the limited number of rows. Use logging to track usage that exceeds the limit. Investigate queries that exceed the default limit for correctness. If correct, use the limit parameter to prevent further warnings.

Tip
titleAdditivity

Setting additivity to false prevents sql being logged to your main confluence log.

Example log

...

Include Page
SUPPORT:How to log SQL activity
SUPPORT:How to log SQL activity