Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Logging from indicator/addon

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Logging from indicator/addon

    Hello, i am using the Debug.WriteLine to log some information for testing and debugging when built in Debug configuration in Visual Studio and this log in the trace file

    When i shift to Release build these no longer appear - of course.

    Is there a way to use the Ninja Log calls without them appearing the control log centre but are written to the log file or even to direct to the trace file.

    Note i dont want the output window as this is for a 3rd party app for some logging information so the output window.

    Can i use Print which will only go to the log/trace file and not the Log in the control centre.

    Any tips/recommendations appreciated

    thanks

    #2
    OK in digging further i see there is the Log.Process alternative

    // Instead of Log()
    NinjaTrader.Cbi.Log.Process(typeof(Resource), "someName", new object[] { "My log message" }, LogLevel.Error, LogCategories.Default, null)

    this will log only to the log file?

    Comment


      #3
      Hello,

      Thanks for your post.

      What I believe you are wanting to do can be accomplished by creating your own custom log file. This concept is detailed in the following forum post about using System.IO File properties to write to and read from a text file: https://ninjatrader.com/support/foru...ead.php?t=3477

      It will also be important to protect you custom text filed from concurrent access. If NinjaTrader tries to access those files at the same time you will run into some undesired errors. You can read more about the Multi-Threading considerations for creating your own custom resources at the following help guide article: https://ninjatrader.com/support/help...-threading.htm

      Please let me know if you have any further questions.
      Josh G.NinjaTrader Customer Service

      Comment


        #4
        Hello so do you recommend to not use the Log.Process - note these are only for infrequent logs of information in the addon/indicator .. so really will suffice for what i am doing ? - i am just logging some trade information when a trade is submitted

        thanks

        Comment


          #5
          Following from the above - i have tried to use the Log.Process and base on an example ... i found in @TextImportType.cs

          Cbi.Log.Process(typeof (Custom.Resource), "ImportTypeNinjaTraderUnexpectedFieldNumber", new object[] {Instrument.FullName, NumberOfDataPoints}, Cbi.LogLevel.Error, Cbi.LogCategories.Default);

          If i call this from my addon/indicator it seems to want to reference NinjaTrader.Gui ..... so i looked up this xml ... so really i dont want or need this stuff ...

          Must i create a resource file ?

          All i need is a form of Log .. which will print to the Log File but NOT to the Control centre? This ,may not exist currently so needs to be added as a new feature?

          I thought the new object[] { } above would enable me to supply the text and values i want printed - and that may depend on the resource.

          Creating my own logging file seems overkill for what i am trying to do and the footprint of the logging is low.

          Thoughts?

          Comment


            #6
            Hello,

            There is not a supported means to accomplish what you are describing. You would need to utilize the methods from both the forum link and the help guide article to accomplish writing to a log and not the Control Center.

            I will submit this as a feature request to our development team for consideration in future releases.

            Please let me know if you have any further questions.
            Josh G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, Today, 02:10 AM
            0 responses
            6 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            11 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            5 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X