Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ASP.NET Core 3 #481

Closed
304NotModified opened this issue Sep 24, 2019 · 13 comments
Closed

Support ASP.NET Core 3 #481

304NotModified opened this issue Sep 24, 2019 · 13 comments
Labels
ASP.NET Core ASP.NET Core - all versions
Milestone

Comments

@304NotModified
Copy link
Member

304NotModified commented Sep 24, 2019

related #480

@304NotModified 304NotModified changed the title Support .NET Core 3 Support ASP.NET Core 3 Sep 24, 2019
@yhnbgfd
Copy link

yhnbgfd commented Sep 29, 2019

3.0:When PublishSingleFile, Nlog cannot log to file.
fix use: ${basedir:processDir=true}

@snakefoot
Copy link
Contributor

@yhnbgfd Please report the unexpected behavior to Microsoft. AppDomain.BaseDirectory should not point to the temporary-directory. Some good places to write your complaint:

dotnet/aspnetcore#12621
https://github.com/dotnet/core-setup/issues/7491

@superdevguy
Copy link

Hi there, i wanted to jump in here and ask if .NET Core 3 support is coming soon. I have a .NET Core 3 application and I am using NLog as shown in the .NET Core 2 sample with a database and fallback to file system if fails. I can't get any logs on the file system or in the database. I pulled the example out of my other working .NET Core 2 application.

Any ideas when it might be supported or if there is a workaround for now?

Thanks!

@304NotModified
Copy link
Member Author

Hi there, i wanted to jump in here and ask if .NET Core 3 support is coming soon. I have a .NET Core 3 application and I am using NLog as shown in the .NET Core 2 sample with a database and fallback to file system if fails. I can't get any logs on the file system or in the database. I pulled the example out of my other working .NET Core 2 application.

Any ideas when it might be supported or if there is a workaround for now?

Thanks!

Is this with PublishSingleFile?

I try to get the .NET core 3 stuff get ready this week. I have unfortunately some troubles running .NET Core 3 myself

@superdevguy
Copy link

Sorry I am not sure what you mean by PublishSingleFile. Can you elaborate a bit more please?

@304NotModified
Copy link
Member Author

Sorry I am not sure what you mean by PublishSingleFile. Can you elaborate a bit more please?

https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/

3.0:When PublishSingleFile, Nlog cannot log to file.
fix use: ${basedir:processDir=true}

@superdevguy
Copy link

superdevguy commented Sep 30, 2019

I tried adding it, but no luck. It is writing the internal-nlog.txt file, but it won't write any of the errors on the file system, or in the database. My config file:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="Info"
      internalLogFile="${basedir}\logs\internal-nlog.txt">
  <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
  </extensions>
  <targets>
    <target xsi:type="FallbackGroup" name="fb1" returnToFirstOnSuccess="true">
      <target name="db"
       xsi:type="Database"
       connectionString="${configsetting::name=ConnectionStrings.Connection}"
       commandType="StoredProcedure"
       commandText="[dbo].[NLog_AddEntry]">
        <parameter name="@machineName"    layout="${machinename}" />
        <parameter name="@logged"           layout="${date}" />
        <parameter name="@level"          layout="${level}" />
        <parameter name="@message"        layout="${message}" />
        <parameter name="@logger"         layout="${logger}" />
        <parameter name="@properties"     layout="${all-event-properties:separator=|}" />
        <parameter name="@callsite"       layout="${callsite}" />
        <parameter name="@exception"      layout="${exception:tostring}" />
      </target>
      <target xsi:type="File" name="ownFile-web" fileName="${basedir:processDir=true}\logs\nlog-app-${shortdate}.log"
          layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
    </target>
  </targets>
  <rules>
    <logger name="Microsoft.*" maxlevel="Error" final="true" />
    <logger name="*" minlevel="Error" writeTo="fb1" />
  </rules>
</nlog>

@snakefoot
Copy link
Contributor

snakefoot commented Sep 30, 2019 via email

@superdevguy
Copy link

No problem finding config file. This is from internal log:

2019-09-30 12:20:18.1752 Info Message Template Auto Format enabled
2019-09-30 12:20:18.1910 Info Loading assembly: NLog.Web.AspNetCore
2019-09-30 12:20:18.2572 Info Adding target FallbackGroupTarget(Name=fb1)
2019-09-30 12:20:18.2909 Info Found 57 configuration items

@superdevguy
Copy link

It is failing to log to the database when an error occurs and also not logging to a file. I am currently just running in development mode on my local machine so it should have 100% access to the stored procedure in the database.

@snakefoot
Copy link
Contributor

snakefoot commented Sep 30, 2019 via email

@superdevguy
Copy link

Thanks guys, turns out the problem was I forgot to Copy to Output Directory. Working fine now!

@304NotModified
Copy link
Member Author

fixed by #496, thanks @snakefoot !

@snakefoot snakefoot added ASP.NET Core ASP.NET Core - all versions and removed ASP.NET Core 3 labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASP.NET Core ASP.NET Core - all versions
Projects
None yet
Development

No branches or pull requests

4 participants