Forum Libraries, Components, and Plugins

How to implement Nlog in xamarin.ios ? & error message should store into Sqlite

Hi Xamarin Team,

In Our Ios project ,we are planing to implement error log using NLog and same error message need to store into SQLlite database

Can you please provide me Sample Solutions .

For C# i refereed some code sniper from c# cornar


  • moljacmoljac HRBeta ✭✭✭

    Last I checked -let say 2 week ago - NLog had no Xamarin.iOS and Xamarin.Android support. I'm not aware of any ports.

    This is onmy list, but I want to finish log4net first

  • jssutahharjssutahhar USMember

    Hi Molijac,

    Thanks for quick reply..

    I got nlog sample application

  • jssutahharjssutahhar USMember
    edited February 2014

    I am facing issue with store message into sqllite databse

    above example it working fine , They are using FileTarget

    I tried databasetarget , Error message not storing into database

    Please find my code below

    private void InitializeNLog()
    var saveDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            _pathToDatabase = Path.Combine(saveDir, "db_sqlite-net.db");
            // Create the database and a table to hold Person information.
            using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))

    // var errorlog = new ErrorLog { Time = "${longdate}", Level = "${level}", Lessage ="${message}", Logger = "${logger}" };
    // using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
    // {
    // db.Insert(errorlog);
    // }

                DatabaseTarget target = new DatabaseTarget();
            target.DBProvider = "System.Data.SQLite.SQLiteConnection, System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139";
            target.ConnectionString = "Data Source="+_pathToDatabase+";Version=3;";
            target.CommandText = "insert into ErrorLog( Time,Level,Lessage,Logger) values(@Time,@Level,@Lessage,@Logger)";
               target.KeepConnection = true;
                target.Parameters.Add(new DatabaseParameterInfo("@Time","${longdate}"));
                target.Parameters.Add(new DatabaseParameterInfo("@Level","${level}"));
            target.Parameters.Add(new DatabaseParameterInfo("@Lessage","${message}"));
            target.Parameters.Add(new DatabaseParameterInfo("@Logger","${logger}"));
            SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Info);
            _logger = LogManager.GetCurrentClassLogger ();
            _logger.Info ("Sample informational message");
  • moljacmoljac HRBeta ✭✭✭

    Sorry I have never used nLog. I do plan to work on component as soon as I finish log4net. In few weeks maybe - if You have that much time

  • Is this problem with SQLite resolved ? Need quick answer

Sign In or Register to comment.