Exemplo n.º 1
0
        /// <summary>
        /// ログ出力
        /// </summary>
        /// <param name="msg">出力内容</param>
        public static void WriteLog(LogSeverity severity, string msg, params object[] args)
        {
            using (FileStream fs = new FileStream(_logFilePath, FileMode.Append))
            {
                Encoding enc = Encoding.GetEncoding(Constants.SJIS);
                using (StreamWriter sw = new StreamWriter(fs, enc))
                {
                    var sb = new StringBuilder();
                    sb.Append(severity.GetStringValue());
                    sb.Append(msg);
                    if (args != null && args.Length > 0)
                    {
                        sb.Append("\t");
                        foreach (string param in args)
                        {
                            sb.Append(param);
                            if (args.Last().ToString() != param)
                            {
                                sb.Append(",");
                            }
                        }
                    }

                    sw.WriteLine(sb.ToString());
                }
            }
        }