Exception if LogBasePath not found
Brought to you by:
dslewis
Hi,
I think you forgot something. When you define a own Folder to log files and this this directory does not exist you will get an exception.
Eg. I try to use
Log.LogBasePath = @"C:\xyz\logs";
My solution to this -> I added in your SetLogPath() the following line:
if (!Directory.Exists(m_logbasepath)) { Directory.CreateDirectory(m_logbasepath); }
right here:
string sFilePath; if (m_logbasepath == string.Empty) { sFilePath = Environment.CurrentDirectory.TrimEnd('\\') + "\\" + LogName + "_" + sPeriod + m_logfiletype; } else { if (!Directory.Exists(m_logbasepath)) { Directory.CreateDirectory(m_logbasepath); } sFilePath = m_logbasepath.TrimEnd('\\') + @"\" + LogName + "_" + sPeriod + m_logfiletype; }
maybe there's a better way to place this line - but this works fine :)
Regards
Robert