/// <summary> /// Logs the specified format. /// </summary> /// <param name="level">The logging level.</param> /// <param name="format">The format.</param> /// <param name="args">The arguments. If an object instance is part of the list, it will be JSON-serialized</param> public virtual void Log(LoggingLevel level, string format, params object[] args) { var loglevel = GetLogLevel(level); if (!_logger.IsEnabled(loglevel)) { return; } if (!string.IsNullOrWhiteSpace(format)) { if (args != null && args.Length > 0) { for (int i = args.Length - 1; i >= 0; i--) { if (args[i] != null) { if (args[i].GetType().IsPrimitiveType()) { continue; } try { args[i] = JsonConvert.SerializeObject(args[i]); } catch { } } } } _logger.Log(loglevel, format, args); logLogic.InsertLog(_logger.Name, HttpContext.Current, level, string.Format(format, args)); } }