Server logging for Aras 31
Hello Experts,
As the title says, we are on Aras 31 and building some custom code in a dll, trying to understand the new way of logging in C# classes
Looking at the release notes here, there is a new way to add logs, the extract from that document
ASP.NET Core native logging mechanism (ILogger and ILoggerFactory) is available in CallContext public object. This mechanism uses server's log configuration and writes server methods logs along with other server's logs. Developers of server methods should use this mechanism for new development. Old public log API in CallContext is depracated with appropriate messages and will be removed in the future
We could not find any documentation on this, the below is the sample we tried but it does not work
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:b1347dfb-7168-424f-b917-016bad5a4fa7:type=csharp&text=CallContext%20CCO%20%3D%20%28%28IOMConnection%29_inn.getConnection%28%29%29.CCO%3B%0AILogger%20_logger%20%3D%20CCO.Logger%3B%0A_logger.LogDebug%28%22Print%20something%22%29%3B]
Do we have an example on how this can be configured?
Can someone please point me in the right direction on this, thanks
Hi Sudhir,
Try this instead:
CCO.Logger.LogError('message');I'll file a doc issue to update the programmer's guide with the right sample.
Hi,
On R32 I'm doing it like this. Hope this helps
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:2e67c496-fc22-408a-ba1c-2b27b4e54496:type=text&text=var%20cco%20%3D%20%28%28Aras.Server.Core.IOMConnection%29%20serverConnection%29.CCO%3B%0Acco.Logger.Log%28LogLevel.Warning%2C%20%24%22Your%20message%20here%22%29%3B]
carstenw
When using the above API, I couldn't find the log file.What we found was we had to add some config in the app setting file
-
Edit the
appsettings.jsonfrom the directory of your Aras Innovator installation e.g.(C:\Aras29\Innovator\Innovator\Server\appsettings.json) -
Update the LoggerConfiguration section from the
appsettings.jsonwith below code. -
"LoggerConfiguration": { "MinimumLevel": { "Default": "Debug" }, "WriteTo": [ { "Name": "File", "Args": { "path": "Logs\Aras_Log.txt", "rollingInterval": "Day" } } ] },
The log file mentioned here was later used by the logger
pls note you will have to restart IIS
-