Adding logging into an indicator/strategy

Modified on Fri, 04 Aug 2023 at 02:25 PM

In order to use the standard mechanism of logging of the platform, the Utils.Common.dll file (which is in the program folder) and using Utils.Common.Logging should be added to the indicator/strategy project.

After this, the extensions of this library (LogDebug, LogInfo, LogWarn and LogError) could be used.

Each extension creates a log with a certain significance level (Debug, Info,Warning and Error). These logs are recorded in the application logs are displayed in the application log window.

Example of use:

public class SampleTick:Indicator
    {
        protected override void OnCalculate(int bar, decimal value)
        {
            this.LogDebug("Debug message");
            this.LogInfo("Info message");
            this.LogWarn("Warn message");
 
            try
            {
                //your code
            }
            catch (Exception e)
            {
                this.LogError("Error message",e);
            }
        }
    }

 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article