Premium Feature — Available in the Professional Plus and Enterprise Editions. Learn more or contact LabKey

You can configure external data sources to log each SQL query, including the user making the query, impersonation information, date and time, and the SQL statement used to query the data source.

Set Up

To configure a data source to log queries, add a Parameter element to the labkey.xml file. For example, if you have a data source named “mySqlDataSource”,

<Resource name="jdbc/mySqlDataSource" auth="Container"        type="javax.sql.DataSource"        username="myname"        password="mypassword"        driverClassName="com.mysql.jdbc.Driver"        url="jdbc:mysql://localhost:3306/?autoReconnect=true&amp;          useUnicode=true&amp;characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull"        maxActive="15"        maxIdle="7"        useInformationSchema="true"        accessToUnderlyingConnectionAllowed="true"        validationQuery="/* ping */"/>

then add the following Parameter element. Note that ":LogQueries" has been appended to the name.

<Parameter name="mySqlDataSource:LogQueries" value="true"/>

The labkey data source itself cannot be configured to log queries in this way. Doing so will cause a warning in the server log at startup -- then startup will proceed as normal.

Viewing Logged SQL Queries

Logged SQL queries can be viewed in the Audit Log. Go to Admin > Site > Admin Console, click Audit Log in the management section, and select Logged sql queries from the dropdown menu.

Related Topics

discussion

Discussion

Search 

Pages 

previousnext
 
expand all collapse all