0
크기가 임계 값에 도달하면 로그 파일 (.txt)을 자동으로 백업하는 방법 (예 : 5MB). 백업 파일 이름은 (log_file_name) _ (system_date)이어야하며 원래 로그 파일은 정리해야합니다 (0KB).자동으로 로그 파일 백업을 수행하는 방법
도와주세요. 미리 감사드립니다.
크기가 임계 값에 도달하면 로그 파일 (.txt)을 자동으로 백업하는 방법 (예 : 5MB). 백업 파일 이름은 (log_file_name) _ (system_date)이어야하며 원래 로그 파일은 정리해야합니다 (0KB).자동으로 로그 파일 백업을 수행하는 방법
도와주세요. 미리 감사드립니다.
lenght()를 사용하여 로그 파일 크기를 확인한 다음 5MB보다 큰 경우 extendLogFile() func을 호출하십시오.
이 u는 easly 자바로 변환 할 수 있습니다 C# 코드입니다
크기 확인 :
if (size > 400 * 100 * 100)
{
extendLogFile(Path);
}
복사 된 로그 아카이브 디렉토리에있는 파일과 새 로그 파일 생성 :
private static void extendLogFile(string lPath)
{
string name = lPath.Substring(0, lPath.LastIndexOf("."));
string UniquName = GenerateUniqueNameUsingDate(); // create a unique name for old log files like '12-04-2013-12-43-00'
string ArchivePath = System.IO.Path.GetDirectoryName(lPath) + "\\Archive";
if (!string.IsNullOrEmpty(ArchivePath) && !System.IO.Directory.Exists(ArchivePath))
{
System.IO.Directory.CreateDirectory(ArchivePath);
}
string newName = ArcivePath + "\\" + UniquName;
if (!File.Exists(newName))
{
File.Copy(lPath, newName + ".txt");
using (FileStream stream = new FileStream(lPath, FileMode.Create))
using (TextWriter writer = new StreamWriter(stream))
{
writer.WriteLine("");
}
}
}
무슨 프로그래밍을 언어? C#, C++ ...? – Mennan
@Mennan - java –