# Turning on the trace facility

Follow these steps to turn on the trace facility.

1. Turn on tracing for all sessions by specifying the following property:

       derby.drda.traceAll=true

   See derby.drda.traceAll property for information on this property.

   Alternatively, while the Network Server is running, you can use the following command (all on one line) to turn on the trace facility:

       java org.apache.derby.drda.NetworkServerControl
         trace on [-s connection-number] [-h hostname][-p portnumber]

   If you specify a connection-number, tracing will be turned on only for that connection.
2. Set the location of the tracing files by specifying the following property:

       derby.drda.traceDirectory=directory-for-tracing-files

   See derby.drda.traceDirectory property for information on this property.

   Alternatively, while the Network Server is running, use the following command (all on one line) to set the trace directory:

       java org.apache.derby.drda.NetworkServerControl traceDirectory
         directory-for-tracing-files [-h hostname] [-p portnumber]

   You need to specify only the directory where the tracing files will reside. The names of the tracing files are determined by the system. If you do not set a trace directory, the tracing files will be placed in `derby.system.home`.

   The Network Server will attempt to create the trace directory (and any parent directories) if they do not exist. This will require that the Java security policy for `derbynet.jar` permits verification of the existence of the named trace directory and all necessary parent directories. For each directory created, the policy must allow

       permission java.io.FilePermission "directory", "read,write";

   For the trace directory itself, the policy must allow

       permission java.io.FilePermission "tracedirectory${/}-", "write";

   See "Configuring Java security" in the Derby Security Guide for information about customizing the Network Server's security policy.

Parent topic: Controlling tracing by using the trace facility