Forum Discussion

sudhir_sbevision_com's avatar
1 year ago
Solved

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]

  • What we found was we had to add some config in the app setting file

    • Edit the appsettings.json from the directory of your Aras Innovator installation e.g.(C:\Aras29\Innovator\Innovator\Server\appsettings.json)

    • Update the LoggerConfiguration section from the appsettings.json with 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

7 Replies

  • eli_donahue's avatar
    eli_donahue
    Community Manager

    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]

    • viettpv's avatar
      viettpv
      Ideator III

      carstenw 

      When using the above API, I couldn't find the log file.

      • sudhir_sbevision_com's avatar
        sudhir_sbevision_com
        Creator I

        What we found was we had to add some config in the app setting file

        • Edit the appsettings.json from the directory of your Aras Innovator installation e.g.(C:\Aras29\Innovator\Innovator\Server\appsettings.json)

        • Update the LoggerConfiguration section from the appsettings.json with 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

  • angela's avatar
    angela
    Catalyst II

    I don´t have an answer, but I support this question! All the mentioned updates regarding Server logging sound useful. I like the unified logs for the various sub servers. But so far I haven´t tested any of the logging features in I14.

    Right now even the latest R33 programmers guide only lists the classic standard log function:

    CCO.Utilities.WriteDebug("logFileName", "logMessage");

    Out of interest: Do you get the mentioned depracted message when using this classic variant?

    • From the Aras method editor, and also from my dll,  i do see a warning

      [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:239f9c8e-cbc2-4065-bd82-514965f86b50:type=text&text=Line%20number%202%2C%20Warning%20Number%3A%20CS0618%2C%20%27Utilities.WriteDebug%28string%2C%20string%29%27%20is%20obsolete%3A%20%27Obsolete%20since%2014.0.%20Use%20CallContext.Logger%20instead.%27]