[]
        
(Showing Draft Content)

Logging

A log file is a textual data file that stores events, processes, messages, and other data.

Log files may be useful for capturing unsuccessful attempts, failed user authentication, or unexpected server overloads. They can help identify slow queries, errors that are causing transactions to take too long or bugs that impact service performance. To be able to capture provider logging, it is necessary to add these properties in the connection string:

  • Log file - Specify the path where each of the log files are stored. If this property is set, the provider will use logging with the default values for Verbosity Level, Log File Size, Log File Count which are described below.

  • Verbosity Level - Numerical value (1-5) that specifies the verbosity of the log. The table below describes what does each value of verbosity log to the file.

    Value Verbose Usage
    5 Verbose Verbose is the noisiest level, rarely (if ever) enabled for a production app.
    4 Debug Debug is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened.
    3 Information Information events describe things happening in the system that correspond to its responsibilities and functions. Generally, these are the observable actions the system can perform.
    2 Warning When service is degraded, endangered, or is behaving outside of its expected parameters, Warning level events are used.
    1 Error When functionality is unavailable or expectations broken, an Error event is used.
    0 Fatal The most critical level, Fatal events demand immediate attention.

    This is an optional property and if it is not set, the default value of 1 will be used.

  • Log File Size - Specify the maximum size (in bytes) of the log file. The default size is 100 MB. The minimum value for Log File Size is 1 MB, and if you specify a value below the minimum, it will be ignored by the provider and the default size is going to be used. Once the maximum has been reached, a new log file will be created in the same folder.

  • Log File Count - A string specifying the maximum file count of log files. Once the maximum has been reached, a new log file is created in the same folder and the oldest log file will be deleted. The default value is 2. A value of 0 or a negative value indicates no limit on the count.

How to use logging

  1. Create a connection string to set up a connection to a provider by setting the following Logging properties.

    string connectionString = string.Format(@"Log File={0};Verbosity Level={1};Log File Count ={2};Log File Size={3},
           "C:\user_system_path\Json.log", 3, 2, 1000000);
    
  2. Fetch data using DataConnectors. The following example implements data retrieval using ADO.NET provider for JSON.

    string connectionString = string.Format(@"Data Model={0};Uri={1};Json Path={2};Use Pool=true;Log File={3};
           Verbosity Level={4};Log File Count ={5}","Document", "test json array.json", "$", "C:\user_system_path\Json.log", 3, 2);
    using (var con = new C1JsonConnection(connectionString))
    {
        con.Open();
        var cmd = con.CreateCommand();
        cmd.CommandText = "select * from [test json array]";
        var reader = cmd.ExecuteReader(); 
    }