Logging on DXP environment

Vote:
 

Hi All,

I would like to log information from single class (not Errors, just INFO kind of messages) on DXP

Is there a way how to do it?

I read this article about logging: "Logging into .Net Diagnostics Trace"

But it didn't make me any clever:)

Is there any more descriptive article or can someone point me to the right direction?

Thank you & Best regards

Petr

#231564
Dec 01, 2020 16:32
Vote:
 

You could:

private static readonly ILogger Logger = LogManager.GetLogger();
logger.Information("Some message");

And in the Integration environment you can change the log level from Error to Information yourself in the Azure Portal:
App Service -> Monitoring -> App Service Logs -> Level.

To change default log level for your other environments, you will need to create a support ticket.

#231565
Edited, Dec 01, 2020 17:17
Vote:
 

But it will change the level of logging for the whole app, right? and also it will log in the same "file" (I know I didn't say it earlier).

I am thinking that in this peticular case it is probably OK to log information in the same log file as the rest of error log, but still... I don't want to log everything from the INFO level for the whole app, just the one class.

And generally: Is there a way how to log a certain level in some part of app to a different log file?

#231591
Dec 02, 2020 8:05
Vote:
 

Install the Application Insights SDK, replace the logger factory that DXP configures automatically, and implement your own that returns a logger that logs both to Application Insights and System.Diagnostics. In the AI SDK you can configure which namespaces should always log, logging level, sampling and whatnot.

#231765
Dec 02, 2020 9:48
Vote:
 

Thank you Johan

#231770
Dec 02, 2020 10:03
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.