Преглед изворни кода

添加记录文本日志方法

长阳分支中职
北京泉江 пре 10 месеци
committed by dao
родитељ
комит
05c67f3c6e
2 измењених фајлова са 35 додато и 0 уклоњено
  1. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj
  2. +33
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Log/LogHelper.cs

+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj Прегледај датотеку

@@ -95,6 +95,7 @@
<Compile Include="DataBase\FieldTypeHepler.cs" />
<Compile Include="DataBase\FieldValueParam.cs" />
<Compile Include="DataBase\DbWhere.cs" />
<Compile Include="Log\LogHelper.cs" />
<Compile Include="Mail\Model\MailAccount .cs" />
<Compile Include="Mail\Model\MailFile.cs" />
<Compile Include="Mail\Model\MailModel.cs" />
@@ -154,6 +155,7 @@
<Analyzer Include="..\..\..\packages\Microsoft.DependencyValidation.Analyzers.0.10.0\analyzers\dotnet\cs\Microsoft.DependencyValidation.Analyzers.resources.dll" />
<Analyzer Include="..\..\..\packages\Microsoft.DependencyValidation.Analyzers.0.10.0\analyzers\dotnet\Microsoft.DependencyValidation.Analyzers.dll" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">


+ 33
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Log/LogHelper.cs Прегледај датотеку

@@ -0,0 +1,33 @@
using System;
using System.IO;

namespace Learun.Util.Log
{
public class LogHelper
{
public static void Info(string msg)
{
try
{
#region log
//文件路径
string path = Path.Combine(Directory.GetCurrentDirectory(), "logs");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}

//文件
string fileName = Path.Combine(path, $"{DateTime.Now:yyyyMMdd}.log");
string message = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} logInfo:{msg}。{Environment.NewLine}";
File.AppendAllText(fileName, message);
#endregion
}
catch
{


}
}
}
}

Loading…
Откажи
Сачувај