Mimer SQL Data Provider
Configuration file examples
Mimer SQL Data Provider > Overview > Trace > Configuration file examples

The following section contains some examples of different MimerTrace.config files. The correct configuration and XML tags are set up automatically if the Mimer SQL Data Provider Trace Control tool is used.

File Trace Listener

A trace configuration that enables tracing of all trace categories. A file trace listener is added without specifying a file name, therefore the trace output will be written to the default file called Mimer.Data.Client.log, located next to MimerTrace.config. DateTime and ProcessId information will be included with every trace message.

Information for all applications will be written to the file. autoFlush is enabled, which forces output from every operation to be written the file.

Please note that even though traceCategory is set to All, the actual output that appears in the trace file depends on the MimerConnection.ConnectionString attribute Allowed Trace Level. If it is set to safe, which is the default then SQL Statements and parameter values are not logged. Only if set to confidential will this information appear in the log file. The reason for this is that sensitive information and/or data about what a user is doing in an application may otherwise be shown. If Allowed Trace Level is none, no tracing is allowed. This may be used, for example, by a an application handling sensitive data in a hospital.

<mimerTrace traceCategory="All">
  <listeners>
    <add type="file" traceOutputOptions="DateTime,ProcessId"/>
  </listeners>
  <trace autoFlush="true"/>
</mimerTrace>

Similar to the configuration above, but the name of the log file has been specified for the trace output, and no traceOutputOptions are set.

<mimerTrace traceCategory="All">
  <listeners>
    <add type="file" filename="C:\Users\username\AppData\Roaming\MimerSQLDataProvider\traceoutput.log"/>
  </listeners>
  <trace autoFlush="true"/>
</mimerTrace>

Database Trace Listener

Below is a trace configuration that enables tracing that includes SQL statements and SQL Parameter values (Note that MimerConnectionStringBuilder.AllowedTraceLevel must be set to 'confidential' to allow this type of tracing). A database listener is added and the database connection string where the trace output is logged in a database is specified.

<mimerTrace traceCategory="SqlStatement, SqlParameter">
  <listeners>
    <add type="database" traceProviderConnectionString="Database=traceDb;Protocol=local;Integrated Security=True;User Id=TraceUser"/>
  </listeners>
</mimerTrace>

When integrated security is set to true in the connection string the current operating system user will be used to login. The user logged in must have the right to login in as the User Id specified in the traceProviderConnectionString.

The following SQL commands create an ident call TraceUser and allows the operating system user abc to login as this user:

CREATE IDENT TraceUser AS USER;
ALTER IDENT TraceUser ADD OS_USER 'domain\abc';
GRANT DATABANK TO TraceUser;

Earlier version of Mimer SQL used unqualified OS user names, eg. OS_USER 'abc'. TraceUser is granted databank privilege so that the Data Provider will be able to create a databank, sequence, and table to store the trace output.

Console Trace Listener

A trace configuration that enables tracing of Errors. Trace output will be written to console.

<mimerTrace traceCategory="Error">
  <listeners>
    <add type="console" traceOutputOptions="ThreadId"/>
  </listeners>
  <trace autoFlush="true"/>
</mimerTrace>

Filtering samples

In the first filtering sample three filters are added which includes tracing of connections where the Application Name is set to App1, excludes traces of databases database1 and database2, and only includes tracing of connections where the user is testuser. All three filter conditions must be fulfilled for a specific connection to be traced.

<mimerTrace traceCategory="All">
  <listeners>
    <add type="database" traceProviderConnectionString="Database=traceDb;Protocol=local;Integrated Security=True;User Id=TraceUser"/>
  </listeners>
  <filters>
     <add type="Application Name" include="true" values="App1"/>
     <add type="Database" include="false" values="database1, database2"/>
     <add type="User Id" include="true" values="testuser"/>
  </filters>
</mimerTrace>

In the next sample, two filters are added which includes traces about database1 (but excludes all other databases), and excludes traces of the SYSADM user. This means that all connections to database1 where SYSADM is not the user will be traced.

<mimerTrace traceCategory="All">
  <listeners>
    <add type="database" traceProviderConnectionString="Database=traceDb;Protocol=local;Integrated Security=True;User Id=TraceUser"/>
  </listeners>
  <filters>
     <add type="Database" include="true" values="database1"/>
     <add type="User Id" include="false" values="SYSADM"/>
  </filters>
</mimerTrace>

Multiple Trace Listeners

Multiple trace listeners can be added by specifying several listeners.

<mimerTrace traceCategory="All">
  <listeners>
    <add type="file" />
    <add type="database" traceProviderConnectionString="Database=traceDb;Password=SYSADM;Protocol=local;User ID=sysadm"/>
  </listeners>
</mimerTrace>

The following section contains some examples of different MimerTrace.config files.

A trace configuration that enables tracing of all trace categories. A file, console, and database listener is added. Autoflush is enabled.

<mimerTrace traceCategory="All">
    <listeners>
       <add type="file" traceOutputOptions="DateTime,ProcessId"/>
       <add type="console" traceOutputOptions="ThreadId"/>
       <add type="database" connectionString="Database=traceDb;Password=SYSADM;Protocol=local;User ID=sysadm"/>
    </listeners>
    <trace autoFlush="true"/>
</mimerTrace>

A trace configuration that enables tracing of SQL statements and SQL Parameters (Note that MimerConnectionStringBuilder.AllowedTraceLevel must be set to 'confidential' on the connection string(s) to get any output). A file listener, specifying a custom file, is added.

<mimerTrace traceCategory="SqlStatement, SqlParameter">
   <listeners>
      <add type="file" filename="C:\Users\username\AppData\Roaming\MimerSQLDataProvider\traceoutput.log"/>
   </listeners>
</mimerTrace>

 

See Also