|
|
|
@ -37,40 +37,41 @@ namespace ServiceLib.Common
|
|
|
|
|
foreach (var filePath in files) |
|
|
|
|
{ |
|
|
|
|
var file = new FileInfo(filePath); |
|
|
|
|
if (file.CreationTime < now) |
|
|
|
|
if (file.CreationTime >= now) continue; |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
file.Delete(); |
|
|
|
|
} |
|
|
|
|
catch { } |
|
|
|
|
file.Delete(); |
|
|
|
|
} |
|
|
|
|
catch |
|
|
|
|
{ |
|
|
|
|
// ignored |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch { } |
|
|
|
|
catch |
|
|
|
|
{ |
|
|
|
|
// ignored |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void SaveLog(string strContent) |
|
|
|
|
{ |
|
|
|
|
if (LogManager.IsLoggingEnabled()) |
|
|
|
|
{ |
|
|
|
|
var logger = LogManager.GetLogger("Log1"); |
|
|
|
|
logger.Info(strContent); |
|
|
|
|
} |
|
|
|
|
if (!LogManager.IsLoggingEnabled()) return; |
|
|
|
|
|
|
|
|
|
LogManager.GetLogger("Log1").Info(strContent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void SaveLog(string strTitle, Exception ex) |
|
|
|
|
{ |
|
|
|
|
if (LogManager.IsLoggingEnabled()) |
|
|
|
|
if (!LogManager.IsLoggingEnabled()) return; |
|
|
|
|
|
|
|
|
|
var logger = LogManager.GetLogger("Log2"); |
|
|
|
|
logger.Debug($"{strTitle},{ex.Message}"); |
|
|
|
|
logger.Debug(ex.StackTrace); |
|
|
|
|
if (ex?.InnerException != null) |
|
|
|
|
{ |
|
|
|
|
var logger = LogManager.GetLogger("Log2"); |
|
|
|
|
logger.Debug($"{strTitle},{ex.Message}"); |
|
|
|
|
logger.Debug(ex.StackTrace); |
|
|
|
|
if (ex?.InnerException != null) |
|
|
|
|
{ |
|
|
|
|
logger.Error(ex.InnerException); |
|
|
|
|
} |
|
|
|
|
logger.Error(ex.InnerException); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|