浏览代码

添加记录文本日志方法

长阳分支中职
北京泉江 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
{


}
}
}
}

正在加载...
取消
保存