Ejemplo n.º 1
0
        private void AddToMongo(string message, string level, string detail = null)
        {
            var entity = new GlobalLogger
            {
                ThreadId    = Thread.CurrentThread.ManagedThreadId,
                Level       = level,
                Message     = message,
                ProjectName = ConfigConstants.ConfigManager.Config.Logger.ProjectName ?? string.Empty,
            };

            MongoManager <GlobalLogger> .Instance.InsertOne(entity);
        }
Ejemplo n.º 2
0
        private void AddToJson(string message, string level, string detail = null)
        {
            var entity = new GlobalLogger
            {
                Level       = level,
                Message     = message,
                ProjectName = ConfigConstants.ConfigManager.Config.Logger.ProjectName ?? string.Empty,
            };

            if (!Directory.Exists(FileUrl))
            {
                Directory.CreateDirectory(FileUrl);
            }
            string filePath = Path.Combine(FileUrl, "Json" + DateTime.Now.ToLongDateString() + ".log");

            using (System.IO.StreamWriter srFile = new System.IO.StreamWriter(filePath, true))
            {
                srFile.WriteLine(Utils.SerializeMemoryHelper.SerializeToJson(entity) + ",");
            }
        }