I have following config
if (Env.IsDevelopment())
{
SetConfig(new HostConfig
{
AddRedirectParamsToQueryString = true,
DebugMode = true
});
}
else
{
SetConfig(new HostConfig
{
AddRedirectParamsToQueryString = true,
DebugMode = false
});
}
I am using Nlog logging. On production server my log files are logging every SQL query. This is making it difficult to monitor exceptions.
Should queries be logged when debug is set to false?
In my systemd service file I have set Environment=ASPNETCORE_ENVIRONMENT=Production
for my production server.
Is it possible to log queries to a separate file or disable it and just log exceptions?
I am using the nlog config from nlog docs:
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="${currentdir}/Logs/nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="${currentdir}/Logs/nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
</targets>
And inside my catch blocks I am using Log.Error()
. Is there any way to configure it so I have log files for different parts of my system so I can say log email errors to one file and import errors to a different file?