Debug & Logging of Plug-In

Hi,

Is there any way to debug Plug-In execution?

I tried to attach to the process of the Trados, but nothing happened.

In addition - what is the best practice for logging in the Plug-In? Is there any unified log storage I should write to, or should I write my logs to a regular file?

Thanks,

Memi

Parents
  • Debugging

    I use 2 ways to debug studio plugins:

    1. Attach to process from Visual Studio. This is my preferred way of debugging but for this to work you need to be careful that Studio loads the assembly that corresponds to your source code. For my plugins I always set the output directly to this path c:\Users\{user}\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Packages\ and then I make sure that the files from c:\Users\{user}\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Unpacked\{plugin name folder} are deleted.

    2. I use this in situation where I need to debug the intialization code or something like that and I don't physically time to attach the VS debugger. This requires to add the following line of code where you want your application to stop for debugging System.Diagnostics.Debugger.Launch()

    In any cases I recommend to compile your plugin with Debug configuration.

    Logging

    Studio uses log4net for logging errors. The drawback of this is that you will not be able to log any other information from your plugin except when the plugin crashes and Studio will catch that exception and write it on the centralized logging file. Based on your needs you can separate logging for your plugin. Studio API doesn't provide anything towards that so you can use whatever you like. I recommend log4net or NLog. Recently I tend to use more NLog but log4net can do the trick just fine. If you want to see how I internalized NLog for one the plugins have a look here

    Hope this helps.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

Reply
  • Debugging

    I use 2 ways to debug studio plugins:

    1. Attach to process from Visual Studio. This is my preferred way of debugging but for this to work you need to be careful that Studio loads the assembly that corresponds to your source code. For my plugins I always set the output directly to this path c:\Users\{user}\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Packages\ and then I make sure that the files from c:\Users\{user}\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Unpacked\{plugin name folder} are deleted.

    2. I use this in situation where I need to debug the intialization code or something like that and I don't physically time to attach the VS debugger. This requires to add the following line of code where you want your application to stop for debugging System.Diagnostics.Debugger.Launch()

    In any cases I recommend to compile your plugin with Debug configuration.

    Logging

    Studio uses log4net for logging errors. The drawback of this is that you will not be able to log any other information from your plugin except when the plugin crashes and Studio will catch that exception and write it on the centralized logging file. Based on your needs you can separate logging for your plugin. Studio API doesn't provide anything towards that so you can use whatever you like. I recommend log4net or NLog. Recently I tend to use more NLog but log4net can do the trick just fine. If you want to see how I internalized NLog for one the plugins have a look here

    Hope this helps.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

Children