Пример #1
0
        public void OnException(ExceptionContext context)
        {
            var response = new ResponseModel <string>()
            {
                code      = 500,
                result    = false,
                errorInfo = context.Exception.Message
            };

            LogFileHelper.WriteLine(context.Exception.Message + "\r\n" + context.Exception.StackTrace);;
            context.Result = new JsonResult(response);
        }
Пример #2
0
        private static void WriteLog(LogLevel level, string tag, object message)
        {
            PerformInitConfig();

            if (!IsPrint || (IsOnlyPrintWarnError && level < LogLevel.Warn))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(tag))
            {
                tag = "Tag";
            }
            if (message == null)
            {
                message = string.Empty;
            }
            CheckLogHelper();
            string content = string.Format("{0} {1}/{2}: {3}", DateTime.Now.ToString("HH:mm:ss:fff"), level, tag, message);

            System.Diagnostics.Debug.WriteLine(content);
            mLogHelper.WriteLine(content);
        }