에러메시지 출력 코드 정리
public class ErrMessage
{
private String message;
private Exception exceptions;
public ErrMessage(String message, Exception exceptions)
{
this.message = message;
this.exceptions = exceptions;
}
public void ErrorMessageWrite()
{
String path = "./DBPErr";
StreamWriter streamWriter;
try
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
path += "/" + DateTime.Now.ToString("yyyy-MM-dd") + ".err";
if (!File.Exists(path))
{
streamWriter = File.CreateText(path);
}
else
{
streamWriter = new StreamWriter(path, true);
}
try
{
streamWriter.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "\\r\\n"
+ message + "\\r\\n" + exceptions.Message + "\\r\\n" + exceptions.StackTrace);
streamWriter.Flush();
}
catch
{
}
finally
{
streamWriter.Close();
}
}
catch
{
}
}
}