SQL Server – How to enable output logging for a replication agent

You can configure the SQL Server replication agents such as, the Snapshot Agent, Log Reader Agent, Queue Reader Agent, Distribution Agent, and Merge Agent to capture more information about error messages and procedure calls to a text file. For example, you can capture the additional information about error messages and procedure calls to troubleshoot agent failures.

The following options are provided for each of the replication agents to enable logging to an output file. If the specified file name exists, the output is appended to the file.

-Output output_path_and_file_name

For Example

-Output C:\Outputfile.txt

The ability to specify whether the output should be verbose. If the verbose level is 0, SQL Server only prints the error messages. If the verbose level is 1, SQL Server prints all the progress report messages. If the verbose level is 2 (default), SQL Server prints all the error messages and progress report messages, which is useful for debugging.

-OutputVerboseLevel [0|1|2]

For example:

-OutputVerboseLevel 2

You can use the following steps with Microsoft SQL Server 2000 Enterprise Manager or Microsoft SQL Server 7.0 Enterprise Manager.

  1. In SQL Enterprise Manager, click the Replication Monitor Node to open the Replication Monitor on the server configured as the Distributor.
  2. Click Open on the Publishers node.
  3. Click the publisher that has the publication that has the problem.
  4. Click Publication.
  5. In the right-hand pane of SQL Enterprise Manager is a list of the agents related to the publication. You see the Snapshot Agent, Log Reader Agent and the Push/Pull Subscription Agent.
  6. Identify the agent for which you need to set up output logging.
  7. Right-click the replication agent you identified in step 6, and then click Agent Properties.
  8. Click the Steps tab, and then edit the Run Agent step.
  9. At the end of the string under command, add:
    -Output C:\Temp\OUTPUTFILE.txt -Outputverboselevel [0|1|2]Specify either 0, 1, or 2 after the -Outputverboselevel parameter.
  10. Click OK to save the changes, and then close the Edit Job Step dialog box.
  11. Click OK to save the changes, and then close the Replication Agent Properties dialog box. If the agent is set to run continuously, stop and restart the replication agent so that SQL Server logs the messages to the log file specified in step 9. If the file already exists, the agent appends the output to the file.

Note If you need to set up the output logging for a Pull Subscription Agent with the SQL Server 7.0 Enterprise Manager, you cannot use the following steps.

2 comments

  • mbourgon

    Actually, that doesn’t work on all the agents. It probably works on the distrib agents, but it doesn’t work on snapshot agents.

    • Hi mbourgon,

      On which SQL Server version have u checked? because it works on the on snapshot agents (SQL Server 2000) You can refer : SQL Server 2000 Books Online.