• Not Answered

Calls to pre-translate in SDK cause NLog configuration change (lost logging/console output redirected to new file)

BACKGROUND

We have a .NET console application which uses the Trados SDK to run jobs for us. We have our own classes to setup/run the jobs, and from within those jobs we call methods in our "Trados2017Api" class, where the actual SDK calls are made. Mostly we are using the Project Automation SDK. We are using SDL Trados Studio 2017 SR1_6278.

When running our application, we setup NLog logging with a LogHandler class (where we add a target for console output), then when running jobs in the job class we setup a logger with "protected static Logger logger = LogManager.GetCurrentClassLogger();" And our Trados2017Api class also does the same thing to get a logger. Normally this setup works great, but unfortunately we are seeing a terrible issue wherein the SDK "steals" our logger output.


PROBLEM
We are seeing problems when we use the SDK to create a Trados project and have added a termbase (sdltb) file to the project during project creation. It seems that when we get to running the Pre-translation step, there is a change in the logging configuration and we lose all console/log file output. All the remaining output goes to "C:\Users\user\AppData\Local\SDL\SDL Language Cloud Terminology Provider\Logs\LCTerminologyProvider.log"

I have added a "ConfigurationChanged" event listener on our LogHandler and I confirm that there is a new logging configuration that gets setup, it appears to be coming from this NLog config file:

Sdl.LanguageCloud.TerminologyProvider.NLog.config

I have confirmed the logging configuration definitely changes after we run this line:

AutomaticTask transTask = project.RunAutomaticTask(targetFiles.GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles);

The last thing we do see in the console output is:

2018-12-18 12:31:22,889 [8836] INFO Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation [(null)] - Batch task max thread count = 3
2018-12-18 12:32:58,352 [STP SmartThreadPool Thread #0] INFO Sdl.MultiTerm.Client.TerminologyProvider.MultiTermTermbase [(null)] - Connected to terminology_data as user 1


SOLUTION/WORKAROUNDS
I can see the new log file path comes from the NLog config file:

${specialfolder:LocalApplicationData}/SDL/SDL Language Cloud Terminology Provider/Logs/LCTerminologyProvider.log

I have tried deleting the config file Sdl.LanguageCloud.TerminologyProvider.NLog.config and it does seem to correct the logging/console and it seems to return to normal.

However, this is a workaround, and we need a permanent fix. This problem is especially bad because once the logging gets set to "LCTerminologyProvider.log" then no matter what job we run, whenever we attempt to use the SDK then suddenly all our output gets lost and redirected to that log file (as in, it seems that NLog file gets used to configure all output for the SDK).

We appreciate your help, thanks.


Related