/// <summary>
        /// Writes log entry
        /// </summary>
        /// <param name="entry"></param>
        public override void Write(LogEntry entry)
        {
            if(!this.IsInitialized)
                this.Initialize();

            var einfo = this.CreateLogEventInfo(entry);
            einfo.LoggerName = this.NLogger.Name;
            this.NLogger.Log(einfo);
        }
        protected LogEventInfo CreateLogEventInfo(LogEntry entry)
        {
            var einfo = new LogEventInfo();

            einfo.Exception = entry.Exception;
            einfo.Message = entry.Message;

            switch (entry.EntryType)
            {
                case LogEntryType.Debug:
                    einfo.Level = LogLevel.Debug;
                    break;
                case LogEntryType.Error:
                    einfo.Level = LogLevel.Error;
                    break;
                case LogEntryType.FatalError:
                    einfo.Level = LogLevel.Fatal;
                    break;
                case LogEntryType.Info:
                    einfo.Level = LogLevel.Info;
                    break;
                case LogEntryType.Warning:
                    einfo.Level = LogLevel.Warn;
                    break;
                default:
                    throw new Exception();
            }

            einfo.Properties["DateTimeUTC"] = entry.DateTimeUTC;
            einfo.Properties["UserID"] = entry.UserID;
            einfo.Properties["Browser"] = (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Browser != null) ? string.Format("{0} {1}", HttpContext.Current.Request.Browser.Browser, HttpContext.Current.Request.Browser.Version) : null;
            einfo.Properties["Application"] = entry.Application;
            einfo.Properties["ApplicationVersion"] = entry.ApplicationVersion;

            foreach (string key in entry.Properties.Keys)
                einfo.Properties[key] = entry.Properties[key];

            return einfo;
        }
        protected virtual void WriteEntry(LogEntry entry)
        {
            this.CheckInit();

            foreach (var logger in this.Loggers.Values)
            {
                try
                {
                    logger.Write(entry);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
 public virtual void WriteWarning(string warn, string userID = null)
 {
     LogEntry entry = new LogEntry();
     entry.EntryType = LogEntryType.Warning;
     entry.Message = warn;
     entry.UserID = userID;
     entry.DateTimeUTC = DateTime.UtcNow;
     entry.Application = this.ApplicationDescriptor.Name;
     entry.ApplicationVersion = this.ApplicationDescriptor.Version;
     this.WriteEntry(entry);
 }
 public virtual void WriteError(string message, bool isFatal = false, string userID = null)
 {
     LogEntry entry = new LogEntry();
     entry.EntryType = isFatal ? LogEntryType.FatalError : LogEntryType.Error;
     entry.Message = message;
     entry.UserID = userID;
     entry.DateTimeUTC = DateTime.UtcNow;
     entry.Application = this.ApplicationDescriptor.Name;
     entry.ApplicationVersion = this.ApplicationDescriptor.Version;
     this.WriteEntry(entry);
 }
        /// <summary>
        /// Writes entry
        /// </summary>
        /// <param name="entry"></param>
        public virtual void Write(LogEntry entry)
        {
            if (object.ReferenceEquals(entry, null))
                throw new NotImplementedException();

            this.CheckInit();

            if (this.IsAsync)
            {
                WaitCallback callback =
                    delegate(object state)
                    {
                        try
                        {
                            this.WriteEntry(state as LogEntry);
                        }
                        catch(Exception ex)
                        {
                            Debug.WriteLine(ex);
                        }
                    };
                ThreadPool.QueueUserWorkItem(callback, entry);
            }
            else
            {
                this.WriteEntry(entry);
            }
        }
 public abstract void Write(LogEntry entry);