我想数数没有。出现 ProductServices 和 Add Product 的行数。
日志是:
INFO [ProductServices] 添加产品已由 gulanand 对 id 为 424 () 的产品执行 INFO [ProductServices] 添加产品已由 gulanand 对 id 为 424 () 的产品执行id 424 () INFO [ProductServices] Update Product has been executed by gulanand on product with id 424 () INFO [ProductServices] Update Product has been executed by gulanand on product with id 424 () INFO [ProductServices] Add Product has been executed by gulanand 在 id 为 424 () 的产品上添加产品 gulanand 对 id 为 424 () 的产品执行了添加产品 gulanand 在 id 为 424 () 的产品上执行
我试过的代码是:
IEnumerable<string> textLines =
Directory.GetFiles(@"C:\Users\karansha\Desktop\Ashish Logs\", "*.*")
.Select(filePath => File.ReadAllLines(filePath))
.SelectMany(line => line);
List<string> users = new List<string>();
Regex r = new Regex(@"*ProductServices\sAdd Product");
foreach (string Line in textLines)
{
if (r.IsMatch(Line))
{
users.Add(Line);
}
}
//string[] textLines1 = new List<string>(users).ToArray();
int countlines = users.Count();
Console.WriteLine("ProductsCreated=" + countlines);