我们已经使用docker在Linux服务器中托管了.net核心api。所以问题是从我们不在容器中的Logs文件夹中读取应用程序日志。我们的docker代码是:
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 50147
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["Services/Services.csproj", "Services/"]
COPY ["Portal.Common/Portal.Common.csproj", "Portal.Common/"]
COPY ["Portal.Domains/Portal.Domains.csproj", "Portal.Domains/"]
COPY ["Portal.Business/Portal.Business.csproj", "Portal.Business/"]
COPY ["Portal.DataAccess/Portal.DataAccess.csproj", "Portal.DataAccess/"]
RUN dotnet restore "PortalServices/PortalServices.csproj"
COPY . .
WORKDIR "/src/PortalServices"
RUN dotnet build "PortalServices.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "PortalServices.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "PortalServices.dll"]
因此在应用程序路径内仅存在dll文件。那么我们如何从文件夹中读取日志?
我们对解决方案实施了serilog并将其保存到solutionpath / Logs / log.txt 在本地,它存储在此路径中。
请帮助!