<system.diagnostics> >> <switches> >> <!-- 0-off, 1-error, 2-warn, 3-info, 4-verbose. --> >> <add name="SyncTracer" value="4" /> >> </switches> >> >> <trace autoflush="true"> >> <listeners> >> <add name="TestListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\temp\SyncLog.txt"/> >> </listeners> >> </trace> >> </system.diagnostics> >>>>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using Microsoft.Synchronization; using Microsoft.Synchronization.Data; using Microsoft.Synchronization.Data.SqlServer; using System.Configuration; using System.IO; namespace SyncBPO { class Program { static void Main(string[] args) { try { string clientConnection = ConfigurationManager.ConnectionStrings["Client"].ConnectionString; string serverConnection = ConfigurationManager.ConnectionStrings["Server"].ConnectionString; string timeoutvalue = ConfigurationManager.AppSettings.GetValues("Timeout").ToString(); int timeout; if (int.TryParse(timeoutvalue, out timeout) == false) { timeout = 300; } // create a connection to the client database SqlConnection clientConn = new SqlConnection(clientConnection); // connect to server database SqlConnection serverConn = new SqlConnection(serverConnection); // create the sync orhcestrator Console.WriteLine("Starting SyncOrchestrator"); SyncOrchestrator syncOrchestrator = new SyncOrchestrator(); // set local provider of orchestrator to a sync provider associated with the // ProductsScope in the SyncExpressDB express client database SqlSyncProvider SQLProviderLocal = new SqlSyncProvider("CompleteScope", clientConn); SQLProviderLocal.CommandTimeout = timeout; syncOrchestrator.LocalProvider = SQLProviderLocal; //new SqlSyncProvider("CompleteScope", clientConn); // set the remote provider of orchestrator to a server sync provider associated with // the ProductsScope in the SyncDB server database SqlSyncProvider SQLProvider = new SqlSyncProvider("CompleteScope", serverConn); SQLProvider.CommandTimeout = timeout; syncOrchestrator.RemoteProvider = SQLProvider; // new SqlSyncProvider("CompleteScope", serverConn); // set the direction of sync session to Upload and Download syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload; // subscribe for errors that occur when applying changes to the client ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed); // execute the synchronization process Console.WriteLine("Starting Synchronisation"); SyncOperationStatistics syncStats = syncOrchestrator.Synchronize(); using (StreamWriter tw = new StreamWriter("BPOSync.log", true)) { tw.WriteLine("Start Time: " + syncStats.SyncStartTime); tw.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal); tw.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal); tw.WriteLine("Complete Time: " + syncStats.SyncEndTime); tw.WriteLine("---"); // close the stream tw.Close(); } } catch (Exception error) { using (StreamWriter tw = new StreamWriter("BPOSyncError.log", true)) { // write a line of text to the file tw.WriteLine(DateTime.Now); tw.WriteLine("Error"); tw.WriteLine(error.ToString()); //tw.WriteLine(error.InnerException); tw.WriteLine("---"); // close the stream tw.Close(); } } } static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e) { // create a writer and open the file //TextWriter tw = new StreamWriter("BPOSync.log"); using (StreamWriter tw = new StreamWriter("BPOSyncChangeFailed.log", true)) { // write a line of text to the file tw.WriteLine(DateTime.Now); tw.WriteLine(e.Conflict.Type); tw.WriteLine(e.Error); tw.WriteLine("---"); // close the stream tw.Close(); } // display conflict type Console.WriteLine(e.Conflict.Type); // display error message Console.WriteLine(e.Error); } } }Where do I put the Trace.Information?