configure serilog with framework 3.5

298 views
Skip to first unread message

Rakesh Kapoor

unread,
Jun 7, 2016, 5:40:31 PM6/7/16
to Serilog
i downloaded serilog-net35 from github and compiled it. are there any samples that i can use. the ones that i copied have a compile issue and i am wondering if i missed something. i just used it in ninjatrader and i have a compile issue with the .writeto line, 

Strategy\testloggingstrateg.cs 'Serilog.Configuration.LoggerSinkConfiguration' does not contain a definition for 'File' and no extension method 'File' accepting a first argument of type 'Serilog.Configuration.LoggerSinkConfiguration' could be found (are you missing a using directive or an assembly reference?)

using Serilog;
using System.IO;
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class testloggingstrateg : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion
private ILogger log;
        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = false;
        }
protected override void OnStartUp()

{
log = new LoggerConfiguration()
.WriteTo.File(@"c:\temp\" + Instrument.FullName + "log.txt")
.CreateLogger();
log.Information("Hello again!" + Instrument.FullName);
}
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
log.Information("Hello again!" + Instrument.FullName);
        }
protected override void OnTermination()
{
    // Clean up your resources here

}
 


Reply all
Reply to author
Forward
0 new messages