//Applicationログを書き込む private static void WriteApplicationLog(string log, LogLevel_Enum logLevel = LogLevel_Enum.Infomation) { string writeValue = "\n"; //Logヘッダー情報を書き込む AddDateTime(ref writeValue); AddLogLevel(ref writeValue, logLevel); //Log情報を出力 writeValue += log; using (FileStream fileStream = new FileStream(applicationLogFilePath, FileMode.Append)) { byte[] byteLog = Encoding.Unicode.GetBytes(writeValue); fileStream.Write(byteLog, 0, byteLog.Length); } }
//ログレベルを付与 private static bool AddLogLevel(ref string logStr, LogLevel_Enum logLevel) { bool result = true; try { string logLevelStr = string.Empty; result = dictionary.TryGetValue(logLevel, out logLevelStr); logStr += logLevelStr; } catch { result = false; } return(result); }