コード例 #1
0
        public void WriteDebugLog(DebugLogMessage log)
        {
            string currentdate = DateTime.Now.ToString("M-d-yyyy");
            string folder      = ConfigurationManagement.Instance.ConfigurationPath;
            string filepath    = folder;
            string filename    = Path.DirectorySeparatorChar + "DebugLog.log";

            FileStream stream;

            if (log != null)
            {
                if (Directory.Exists(filepath))
                {
                    if (File.Exists(filepath + filename))
                    {
                        stream = new FileStream(filepath + filename, FileMode.Append, FileAccess.Write, FileShare.Write);
                    }
                    else
                    {
                        stream = new FileStream(filepath + filename, FileMode.CreateNew, FileAccess.Write, FileShare.Write);
                    }

                    StreamWriter m_streamWriter = new StreamWriter(stream);
                    // write out the current date and message
                    // followed by the source and a stack trace
                    m_streamWriter.WriteLine(currentdate + " " + log.ToString());

                    m_streamWriter.Close();
                    stream.Close();
                }
            }
        }
コード例 #2
0
ファイル: LogCenter.cs プロジェクト: zzz654321/fireBwall
        public void WriteDebugLog(DebugLogMessage log)
        {
            string currentdate = DateTime.Now.ToString("M-d-yyyy");
            string folder = ConfigurationManagement.Instance.ConfigurationPath + Path.DirectorySeparatorChar + "Log";
            if (!Directory.Exists(folder))
                Directory.CreateDirectory(folder);
            string filepath = folder;
            string filename = Path.DirectorySeparatorChar + "DebugLog.log";

            FileStream stream;
            if (log != null)
            {
                if (Directory.Exists(filepath))
                {
                    if (File.Exists(filepath + filename))
                        stream = new FileStream(filepath + filename, FileMode.Append, FileAccess.Write, FileShare.Write);
                    else
                        stream = new FileStream(filepath + filename, FileMode.CreateNew, FileAccess.Write, FileShare.Write);

                    StreamWriter m_streamWriter = new StreamWriter(stream);
                    // write out the current date and message
                    // followed by the source and a stack trace
                    m_streamWriter.WriteLine(currentdate + " "+ log.ToString());

                    m_streamWriter.Close();
                    stream.Close();
                }
            }
        }