private void AppendToLog(object sender, CommandExecutionEventArgs e)
 {
     if (this.logOutput != null)
     {
         this.logOutput.WriteLine(e.ToTraceString().TrimEnd());
         this.logOutput.WriteLine();
     }
 }
Пример #2
0
 private void AppendToLog(object sender, CommandExecutionEventArgs e)
 {
     if ( logger != null)
     {
         logger.Debug(e.ToTraceString().TrimEnd());
     }
 }
Пример #3
0
        /// <summary>
        /// The logging method.  Overwrite this method to change the logging strategy.
        /// </summary>
        /// <param name="e">
        /// The DB command event.
        /// </param>
        /// <param name="commState">
        /// Command State 
        /// </param>
        private void LogSql(CommandExecutionEventArgs e, CommandState commState)
        {
            switch (commState)
            {
                case CommandState.CommandExecuting:
                    stopwatch.Start();
                    log.InfoFormat(
                        "[Database: {0}] - Executing command {1}", e.Command.Connection.Database, e.ToTraceString());
                    break;
                case CommandState.CommandFailed:
                    stopwatch.Stop();
                    log.InfoFormat(
                        "[Database: {0}] - Executing command {1} was FAILED", e.Command.Connection.Database,
                        e.ToTraceString());
                    break;
                case CommandState.CommandFinished:
                    stopwatch.Stop();
                    if (stopwatch.ElapsedMilliseconds > MaxTimeAllowPerServiceMethod)
                    {
                        log.WarnFormat("Execute for command take: [{0} ms], it is exceed 2s",
                                       stopwatch.ElapsedMilliseconds);
                    }

                    log.InfoFormat("Finished execute command. It takes: {0} millisecond", stopwatch.ElapsedMilliseconds);
                    break;
            }
        }
 private void OnCommandExecuting(object sender, CommandExecutionEventArgs e)
 {
     if (_log != null)
     {
         _log.WriteLine(string.Format("#{0} Running {1}:\r\n{2}", e.CommandId, e.Method.Trim(), e.ToTraceString().Trim()), "Information");
     }
 }