Hi Manoj Kumawat
Thank you for your reply. That sounds promising, since we are also using Serilog. So it must be due to some misconfiguration on my part.
Can you provide insight into which loging sources and LogLevels you have configured to get good insight into the commerce import process?
Can you also provide examples of log statements that you can see in your log, so I can try to see if I can duplicate this?
Thank you very much for your help.
Regards
Anders
Hello Anders, I will try to explain steps included in setup for Serilog. I am sure you might have something similar to it.
Appsettings.json - We have set it to Level Warning on Production and writing it to both console and file.
"Serilog": {
"Using": [],
"MinimumLevel": {
"Default": "Warning",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId",
"WithThreadId"
],
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": "App_Data/EPiServerErrors.log.txt",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:G} {Message}{NewLine:1}{Exception:1}"
}
}
]
}
Program.cs - reading if from context file. e.g. appsettings.{env}.json
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureCmsDefaults()
.UseSerilog(
(context, configuration) => { configuration.ReadFrom.Configuration(context.Configuration); })
.ConfigureAppConfiguration((ctx, builder) => { builder.AddConfiguration(Configuration); })
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
Logging it in a service (example usage)
using Serilog;
namespace Test.EpiServer.Controllers;
public class TestController : ControllerBase
{
private readonly ILogger _logger;
public TestController()
{
_logger = Log.ForContext(typeof(TestController));
}
public void TestResults()
{
_logger.Error("Logging Error in TestMethod called.");
}
}
I might have missed some references to include but this is what it basically did for us.
Hi,
Did you try to set log level in appSettings.json like this:
I think it should work by default
Hi Manoj and Binh
Thank you for your help.
I will take a look at my configuration again and try to do some tests. It must be something that I haven't configured properly.
Hi Forum
Is there a way to setup logging/tracing so that I can get some insight into how Commerce is importing data using catalog.xml files?
I have been able to do this in an earlier version of Optimizely Commerce, I believe that was with the Log4Net setup. Can I still do this with the new Logging API?
I have tried to enable Debug logging on "Episerver" and "Mediachase" but I don't see anything interresting in my logfiles. So either I'm doing something wrong, or the possibility to get this insight is gone?