Beispiel #1
0
        private static void WriteLog(LogType type, string tag, string msg)
        {
            string logPath = GeneralHelper.CurrentPath() + @"\Log\";

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }
            try
            {
                IDictionary <LogType, string> logMap = new Dictionary <LogType, string>();
                logMap.Add(LogType.VERBOSE, " VERBOSE ");
                logMap.Add(LogType.DEBUG, " DEBUG ");
                logMap.Add(LogType.INFO, " INFO ");
                logMap.Add(LogType.WARN, " WARN ");
                logMap.Add(LogType.ERROR, " ERROR ");

                msg = new StringBuilder().Append("\r\n")
                      .Append(GetDateformat(Dateformat.yyyyMMddHHmmss))
                      .Append(logMap[type]).Append(tag).Append(" ")
                      .Append(msg).ToString();

                string fileName = new StringBuilder()
                                  .Append(GetDateformat(Dateformat.yyyyMMdd))
                                  .Append(".log").ToString();

                RecordLog(logPath, fileName, msg);
            }
            catch (Exception e)
            {
                LogUtil.Trace(LogType.ERROR, "LogUtil: ", e.Message);
            }
        }